#include <thread.h>
Collaboration diagram for ExecutionThread:
Public Member Functions | |
ExecutionThread () | |
Constructor; actually does nothing :). | |
virtual | ~ExecutionThread () |
int | start () |
Start a new thread and have it execute the function run(). | |
bool | running () |
See if the thread is currently running or not. | |
Protected Member Functions | |
virtual void | run () |
void | exit () |
void | yield () |
Private Member Functions | |
ExecutionThread (const ExecutionThread &) | |
Do not use these:. | |
void | operator= (const ExecutionThread &) |
Private Attributes | |
ThreadKernel::TNode * | handle |
Friends | |
class | ThreadKernel |
In order to make use of this class, you must derive a class from this one and override the virtual function run(). To start the thread, call start(); this will execute run() in a new thread. When run() returns, or the thread calls exit(), the thread exits. The object itself, however, will remain existant and you can re-start a new thread using start().
Definition at line 158 of file thread.h.
|
Do not use these:.
|
|
Constructor; actually does nothing :).
Definition at line 268 of file thread.cc. References handle. |
|
Destructor: It is legal to destroy a thread if it is still running. In this case, the thread will continue to run until it exits normally. Definition at line 273 of file thread.cc. References ThreadKernel::unregister(). |
|
This must be called from within the running thread if it wishes to to exit. (This is like returning from run()). |
|
|
|
This is executed by the new thread; in order for this class to be useful, you should override this function. Definition at line 259 of file thread.cc. Referenced by ThreadKernel::_ThreadFuncWrapper(). |
|
See if the thread is currently running or not. If you successfully started a thread before and it is not running then that means that the thread finished. Definition at line 218 of file thread.h. References handle. |
|
Start a new thread and have it execute the function run(). Note that the start function itself is not thread-safe; this means you must not call this start() simultaniously from several threads; in case you get such situations, protect the ExecutionThread with a mutex. It is guaranteed that there is no "dead time" between the return of start() and when running() becomes true. If running() is false the first time (or any time) you call it after start(), it means that the thread already exited.
We must "wait" until the ThreadManager knows of the new thread, i.e. the new thread executed the wrapper function. This is just a few CPU instructions and hence a single yield should be enough. Definition at line 215 of file thread.cc. References handle. |
|
This can be called from within the running thread to give way to other threads waiting to be scheduled. Normally not needed! |
|
|
|
Internal thread structure as allocated by the ThreadKernel. If this is NULL, the thread is not running, if non-NULL, it points to ThreadKernel's internal handle for the thread. Definition at line 165 of file thread.h. Referenced by ThreadKernel::_PhookNotifier(), ThreadKernel::_ThreadFuncWrapper(), ThreadKernel::_unregister(), ExecutionThread(), running(), and start(). |