MADNESS
version 0.9
|
Simplified thread wrapper to hide pthread complexity. More...
#include <worldthread.h>
Public Member Functions | |
ThreadBase () | |
Default constructor ... must invoke start() to actually begin the thread. More... | |
virtual | ~ThreadBase () |
virtual void | run ()=0 |
You implement this to do useful work. More... | |
void | start () |
Start the thread running. More... | |
const pthread_t & | get_id () const |
Get the pthread id of this thread (if running) More... | |
int | get_pool_thread_index () const |
Get index of thread in ThreadPool (0,...,nthread-1) or -1 if not in ThreadPool. More... | |
int | cancel () const |
Cancel this thread. More... | |
Static Public Member Functions | |
static void | exit () |
A thread can call this to terminate its execution. More... | |
static int | num_hw_processors () |
Get no. of actual hardware processors. More... | |
static void | set_affinity_pattern (const bool bind[3], const int cpu[3]) |
Specify the affinity pattern or how to bind threads to cpus. More... | |
static void | set_affinity (int logical_id, int ind=-1) |
static ThreadBase * | this_thread () |
Friends | |
class | ThreadPool |
Simplified thread wrapper to hide pthread complexity.
If the thread is using any of the object state you cannot delete the object until the thread has terminated.
The cleanest solution is to put the object on the heap and have the run method "delete this" at its end.
|
inline |
Default constructor ... must invoke start()
to actually begin the thread.
|
inlinevirtual |
|
inline |
Cancel this thread.
References get_id().
|
inlinestatic |
A thread can call this to terminate its execution.
|
inline |
Get the pthread id of this thread (if running)
Referenced by cancel().
|
inline |
Get index of thread in ThreadPool (0,...,nthread-1) or -1 if not in ThreadPool.
|
static |
Get no. of actual hardware processors.
References MADNESS_EXCEPTION.
Referenced by set_affinity_pattern().
|
pure virtual |
You implement this to do useful work.
|
static |
Referenced by madness::initialize().
|
static |
Specify the affinity pattern or how to bind threads to cpus.
References num_hw_processors().
Referenced by madness::initialize().
void madness::ThreadBase::start | ( | ) |
Start the thread running.
References MADNESS_EXCEPTION.
Referenced by madness::Thread::start(), and madness::Thread::Thread().
|
inlinestatic |
Referenced by madness::ThreadPool::run_task().
|
friend |