FRIBParallelanalysis
1.0
FrameworkforMPIParalleldataanalysisatFRIB
|
#include <CTCLThread.h>
Public Member Functions | |
CTCLThread (int flags=TCL_THREAD_JOINABLE, int stacksize=TCL_THREAD_STACK_DEFAULT) | |
virtual | ~CTCLThread () |
void | start (ClientData pData=nullptr) |
void | requestExit () |
virtual int | operator() (ClientData arg)=0 |
virtual void | exitHandler () |
int | join () |
Static Public Member Functions | |
static Tcl_ThreadId | currentThread () |
Protected Member Functions | |
bool | exitRequested () const |
Concrete derivations of this class are instances of threads that are started using the TCL API (Tcl_CreateThread).
CTCLThread::CTCLThread | ( | int | flags = TCL_THREAD_JOINABLE , |
int | stacksize = TCL_THREAD_STACK_DEFAULT |
||
) |
constructor We save the stack and flags for when start is called at which point they'll be needed.
flags | - start flags. |
stacksize | - bytes in stack. |
|
virtual |
destructor This must be used with caution. Ideally the sequence is
|
static |
currentThread [static] Returns the current thread id
|
virtual |
exitHandler The runTrampoline, running in the context of the thread, always sets up an exit handler which, eventually invokes us. Since exit handlers are optional, we provide a default do-nothing handler. Tcl provides for a chain of handlers. This is less appropriate for an object oriented thread. We do recommend, however that at an appropriate time, overrides of this invoke the base class exit handler so we get object oriented exit handler chaning.
|
protected |
exitRequested
int CTCLThread::join | ( | ) |
join If the thread is joinable and running it can be joined here. If this is not the case, an exception will be thrown
std::logic_error | if join could not be done. |
void CTCLThread::requestExit | ( | ) |
requestExit There's no way to actually force the exit of a thread. What we can do is set a flag (m_exitRequested) and hope the thread looks at it from time to time (via exitRequested) and, when its true cleans up and exits. There is no penalty to ask for an exit more than once.
void CTCLThread::start | ( | ClientData | pData = nullptr | ) |
start Starts the thread:
pData | - argument to pass to operator() - defaults to a nullptr. |