Sack Library Documentation
ContentsIndexReferenceHome
PreviousUpNext
sack::timers::IsThisThreadEx Function
C++
IMPORT_METHOD int IsThisThreadEx(PTHREAD pThreadTest DBG_PASS);
#define IsThisThread(thread) IsThisThreadEx(thread DBG_SRC)
Parameters 
Description 
thread 
thread to check to see if it is the current thread. 

TRUE if this thread is the same as the PTHREAD passed. otherwise FALSE.

This tests to see if a pointer to a thread references the current thread.

PTHREAD main_thread;
LOGICAL thread_finished_check;
   
PTRSZVAL CPROC ThreadProc( PTHREAD thread )
{
    if( IsThisThread( main_thread ) )
         printf( "This thread is not the main thread.\n" );
    else
         printf( "This is the main thread - cannot happen :)\n" );
   
    // mark that this thread is complete
    thread_finished_check = TRUE;
   
    // hmm - for some reason, just pass the PTRSZVAL that was passed to ThreadTo as the result.
    return GetThreadParam( thread );
}
   
int main( void )
{
     main_thread = MakeThread();
     ThreadTo( ThreadProc, 0 );
   
     // wait for the thread to finish its thread identity check.
     while( !thread_finished_check )
         Relinquish();
   
     return 0;
}
Created with a commercial version of Doc-O-Matic. In order to make this message disappear you need to register this software. If you have problems registering this software please contact us at support@toolsfactory.com.
Copyright (c) 2000+. All rights reserved.
What do you think about this topic? Send feedback!