SCIRun
5.0
|
#include <Thread.h>
Public Types | |
enum | ActiveState { Activated, Stopped, NotActivated } |
Possible thread start states. More... | |
Public Member Functions | |
Thread (Runnable *runner, const char *name, ThreadGroup *group=0, ActiveState state=Activated, unsigned long long stack_size=DEFAULT_STACKSIZE) | |
ThreadGroup * | getThreadGroup () |
Return the ThreadGroup associated with this thread. More... | |
Runnable * | getRunnable () |
Return the Runnable associated with this thread. More... | |
void | setDaemon (bool to=true) |
bool | isDaemon () const |
Returns true if the thread is tagged as a daemon thread. More... | |
void | activate (bool stopped) |
void | detach () |
bool | isDetached () const |
Returns true if the thread is detached. More... | |
void | setStackSize (unsigned long long stackSize) |
unsigned long long | getStackSize () const |
Returns the stack size for the thread. More... | |
void | stop () |
Stop the thread. More... | |
void | resume () |
Resume the thread. More... | |
void | join () |
const char * | getThreadName () const |
Returns the name of the thread. More... | |
void | migrate (int proc) |
Static Public Member Functions | |
static void | exitAll (int code) |
Kill all threads and exit with code. More... | |
static void | exit () |
Exit the currently running thread. More... | |
static Thread * | self () |
Returns a pointer to the currently running thread. More... | |
static int | numProcessors () |
Returns the number of processors on the system. More... | |
static ThreadGroup * | parallel (ParallelBase &helper, int nthreads, bool block, ThreadGroup *threadGroup=0) |
template<class T > | |
static void | parallel (T *ptr, void(T::*pmf)(int), int numThreads) |
template<class T , class Arg1 > | |
static void | parallel (T *ptr, void(T::*pmf)(int, Arg1), int numThreads, Arg1 a1) |
Another overloaded version of parallel that passes 1 argument. More... | |
template<class T , class Arg1 , class Arg2 > | |
static void | parallel (T *ptr, void(T::*pmf)(int, Arg1, Arg2), int numThreads, Arg1 a1, Arg2 a2) |
Another overloaded version of parallel that passes 2 arguments. More... | |
template<class T , class Arg1 , class Arg2 , class Arg3 > | |
static void | parallel (T *ptr, void(T::*pmf)(int, Arg1, Arg2, Arg3), int numThreads, Arg1 a1, Arg2 a2, Arg3 a3) |
Another overloaded version of parallel that passes 3 arguments. More... | |
template<class T , class Arg1 , class Arg2 , class Arg3 , class Arg4 > | |
static void | parallel (T *ptr, void(T::*pmf)(int, Arg1, Arg2, Arg3, Arg4), int numThreads, Arg1 a1, Arg2 a2, Arg3 a3, Arg4 a4) |
Another overloaded version of parallel that passes 4 arguments. More... | |
static void | niceAbort (void *Context=0) |
static int | couldBlock (const char *why) |
static void | couldBlockDone (int restore) |
static void | yield () |
The calling process voluntarily gives up time to another process. More... | |
static bool | isInitialized () |
static void | setDefaultAbortMode (const char *abortMode) |
static void | initialize () |
Friends | |
class | Runnable |
class | ConditionVariable |
class | RecursiveMutex |
class | Mutex |
struct | Thread_private |
class | SystemCallManager |
void | Thread_run (Thread *t) |
void | Thread_shutdown (Thread *, bool) |
void * | run_threads (void *priv_v) |
void | handle_abort_signals (int, siginfo_t *, void *) |
void | handle_quit (int) |
void | handle_siguser2 (int) |
void | install_signal_handlers () |
void | exit_handler () |
The Thread class provides a new context in which to run. A single Runnable class is attached to a single Thread class, which are executed in another thread.
enum ActiveState |
Thread | ( | Runnable * | runner, |
const char * | name, | ||
ThreadGroup * | group = 0 , |
||
ActiveState | state = Activated , |
||
unsigned long long | stack_size = DEFAULT_STACKSIZE |
||
) |
Create a thread, which will execute the run() method in the runner object. The thread name is used for identification purposes, and does not need to be unique with respect to other threads. Group specifies the ThreadGroup that to which this thread should belong. If no group is specified (group==0), the default group is used.
void activate | ( | bool | stopped | ) |
If the thread is started in the the NotActivated state, use this to activate the thread (the argument should be false).
|
static |
Mark a section as one that could block for debugging purposes. The int that is returned should be passed into couldBlockDone(int) when the section has completed. This will typically not be used outside of the thread implementation.
|
static |
Mark the end of a selection that could block. restore was returned from a previous invocation of the above couldBlock.
void detach | ( | ) |
Arrange to have the thread deleted automatically at exit. The pointer to the thread should not be used by any other threads once this has been called.
|
static |
Exit the currently running thread.
|
static |
Kill all threads and exit with code.
Runnable* getRunnable | ( | ) |
Return the Runnable associated with this thread.
unsigned long long getStackSize | ( | ) | const |
Returns the stack size for the thread.
ThreadGroup* getThreadGroup | ( | ) |
Return the ThreadGroup associated with this thread.
const char* getThreadName | ( | ) | const |
Returns the name of the thread.
|
static |
bool isDaemon | ( | ) | const |
Returns true if the thread is tagged as a daemon thread.
bool isDetached | ( | ) | const |
Returns true if the thread is detached.
|
static |
Return true if the thread library has been initialized. This will typically not be used outside of the thread implementation.
void join | ( | ) |
Blocks the calling thread until this thead has finished executing. You cannot join detached threads or daemon threads.
void migrate | ( | int | proc | ) |
Request that the thread migrate to processor proc. If proc is -1, then the thread is free to run anywhere.
|
static |
Abort the current thread, or the process. Prints a message on stderr, and the user may choose one of:
continue(c)/dbx(d)/cvd(v)/kill thread(k)/exit(e)
context is necesary on Windows to catch a segfault
|
static |
Returns the number of processors on the system.
|
static |
Start up several threads that will run in parallel. A new ThreadGroup is created as a child of the optional parent. If block is true, then the caller will block until all of the threads return. Otherwise, the call will return immediately.
|
inlinestatic |
Start up several threads that will run in parallel. If block is true, then the caller will block until all of the threads return. Otherwise, the call will return immediately.
|
inlinestatic |
Another overloaded version of parallel that passes 1 argument.
|
inlinestatic |
Another overloaded version of parallel that passes 2 arguments.
|
inlinestatic |
Another overloaded version of parallel that passes 3 arguments.
|
inlinestatic |
Another overloaded version of parallel that passes 4 arguments.
void resume | ( | ) |
Resume the thread.
|
static |
Returns a pointer to the currently running thread.
void setDaemon | ( | bool | to = true | ) |
Flag the thread as a daemon thread. When all non-deamon threads exit, the program will exit.
|
static |
set to "exit" (or something else) so we don't have to always wait for the user to input something
void setStackSize | ( | unsigned long long | stackSize | ) |
Set the stack size for a particular thread. In order to use this thread, you must create the thread in the NotActivated state, set the stack size, and then start the thread using activate(false). Setting the stack size for a thread that is running or has ever been run, will throw an exception. The units are in bytes.
void stop | ( | ) |
Stop the thread.
|
static |
The calling process voluntarily gives up time to another process.
|
friend |
|
friend |
|
friend |
|
friend |
|
friend |
Make sure the exiting information is stored on the local stack In case we cannot access the structures any more
If not exiting tell we are running again
|
friend |
|
friend |
|
friend |
|
friend |
|
friend |
|
friend |
|
friend |
|
friend |
|
friend |