#include <thread.hpp>
Public Member Functions | |
Thread (const T &startclass) | |
Cosntructor - pass in a functional object. | |
~Thread () | |
void * | join () |
The functor object must support copy construction: The Thread class copies the object to a heap allocated object, then spawns a thread on it. This allows the original object to go out of scope without causing segmentation faults.
The copied object is deleted when the thread exists.
Once a Thread instance is created an operating system thread is created and the operator() method of the provided class reference is invoked.
Parameters are not passable to the thread using the construction mechanism - rather instead, all parameters should be passed in using the functor's constructor.
Threads may be joined using the join method. Calling join on a thread from the parent thread will cause the parent thread to block until the child has terminated.
Note: Class Thread is unavailable when MYNAHSA_USE_BOOST is set as a compile time option.
no handling of potential failures in thread creation.
Definition at line 145 of file thread.hpp.
|
Destructor: In the event of the thread being thrown away, we detach, allowing memory to be recovered on thread termination. Definition at line 168 of file thread.hpp.
|
|
Join a thread. On Win32 will return 0 by default. On unix will return whatever the called thread returned. Definition at line 176 of file thread.hpp. 00176 { 00177 #ifdef WIN32 00178 WaitForSingleObject( _hThread, INFINITE ); 00179 return 0; 00180 #else 00181 void* vrtn; 00182 pthread_join(_thread,&vrtn); 00183 return vrtn; 00184 #endif 00185 }
|