#include <thread.h>

Public Types | |
| typedef pthread_t | native_handler_type |
Public Member Functions | |
| Thread () | |
| Thread (int id) | |
| Thread (string n, Runnable *r=NULL) | |
| Thread (Runnable *r) | |
| Create a new thread from a runnable object. | |
| template<class F> | |
| Thread (F &f) | |
| This constructor will create a thread from a function object directly. The new thread will be start imediately. This class is in compatible with the C++ 0X standard. | |
| virtual void * | run () |
| default run() method, which is intended to be overrided by subclass. | |
| void | setRunner (Runnable *r) |
| set internal runner of this thread. | |
| void | start () |
| Start to execute this thread. | |
| native_handler_type | native_handle () |
| return OS handler of background OS handler | |
| void | setName (string name) |
| string | getName () |
| void | join () |
| caller thread will be blocked until this thread exits. | |
| bool | joinable () const |
| this method is used to tell if this thread can be joined. TODO: if a thread is not started, it's not joinable. Modify it! | |
| void | detach () |
| Detach this thread object with background OS thread. | |
| virtual | ~Thread () |
Static Public Member Functions | |
| template<class F> | |
| static void * | callFuncObj (void *ob) |
| Helper function which calls a function object. | |
Protected Attributes | |
| int | threadId |
| pthread_t | tid |
| string | name |
We should use Function object in all of the library code unless executor framework is used. Runnable object is only for using with executor framework.
| typedef pthread_t amino::Thread::native_handler_type |
| amino::Thread::Thread | ( | ) | [inline] |
| amino::Thread::Thread | ( | int | id | ) | [inline] |
| amino::Thread::Thread | ( | string | n, | |
| Runnable * | r = NULL | |||
| ) | [inline] |
Create a new thread with a runnable object.
| amino::Thread::Thread | ( | Runnable * | r | ) | [inline] |
Create a new thread from a runnable object.
| amino::Thread::Thread | ( | F & | f | ) | [inline, explicit] |
This constructor will create a thread from a function object directly. The new thread will be start imediately. This class is in compatible with the C++ 0X standard.
| f | A function object which will be executed in another thread. |
| virtual amino::Thread::~Thread | ( | ) | [inline, virtual] |
| static void* amino::Thread::callFuncObj | ( | void * | ob | ) | [inline, static] |
Helper function which calls a function object.
This function exists for calling function object from a pthread call
| virtual void* amino::Thread::run | ( | ) | [inline, virtual] |
default run() method, which is intended to be overrided by subclass.
Implements amino::Runnable.
Reimplemented in test::ConditionThread, test::LockThread, test::RecursiveLockThread, test::MutexThread, test::RecursiveMutexThread, ThreadMath< ParaType, CLASS_NAME >, test::Thread4Dir< DequeType, ParaType, CLASS_NAME >, test::ThreadPushRight< DequeType, ParaType, CLASS_NAME >, test::TakeThread< DequeType, ParaType, CLASS_NAME >, test::PushThread< DequeType, ParaType, CLASS_NAME >, test::Thread4Dir< DequeType, ParaType, CLASS_NAME >, test::Thread4Dir< DequeType, ParaType, CLASS_NAME >, test::ThreadPushRight< DequeType, ParaType, CLASS_NAME >, test::ThreadInsert< DictType, ParaType, CLASS_NAME >, test::ThreadDeleteKey< DictType, ParaType, CLASS_NAME >, test::ThreadDeleteValue< DictType, ParaType, CLASS_NAME >, test::ThreadFindValue< DictType, ParaType, CLASS_NAME >, test::ThreadFindKey< DictType, ParaType, CLASS_NAME >, test::ThreadInsert< DictType, ParaType, CLASS_NAME >, test::ThreadInsert< DictType, ParaType, CLASS_NAME >, test::ThreadPush_front< ListType, ParaType, CLASS_NAME >, test::ThreadRemove< ListType, ParaType, CLASS_NAME >, test::ThreadEnqueue< QueueType, ParaType, CLASS_NAME >, test::ThreadDequeue< QueueType, ParaType, CLASS_NAME >, test::ThreadEnqueue< QueueType, ParaType, CLASS_NAME >, test::ThreadDequeue< QueueType, ParaType, CLASS_NAME >, test::ThreadInsert< DictType, ParaType, CLASS_NAME >, test::ThreadRemove< ListType, ParaType, CLASS_NAME >, test::ThreadPush< TestType, ParaType, CLASS_NAME >, and test::ThreadPop< TestType, ParaType, CLASS_NAME >.
| void amino::Thread::setRunner | ( | Runnable * | r | ) | [inline] |
| void amino::Thread::start | ( | ) | [inline] |
Start to execute this thread.
If the runner is set, it will be executed. If not, the thread.run() method will be executed.
| native_handler_type amino::Thread::native_handle | ( | ) | [inline] |
return OS handler of background OS handler
| void amino::Thread::setName | ( | string | name | ) | [inline] |
| string amino::Thread::getName | ( | ) | [inline] |
| void amino::Thread::join | ( | ) | [inline] |
caller thread will be blocked until this thread exits.
| bool amino::Thread::joinable | ( | ) | const [inline] |
this method is used to tell if this thread can be joined. TODO: if a thread is not started, it's not joinable. Modify it!
| void amino::Thread::detach | ( | ) | [inline] |
Detach this thread object with background OS thread.
int amino::Thread::threadId [protected] |
pthread_t amino::Thread::tid [protected] |
string amino::Thread::name [protected] |
1.5.6