Code::Blocks
SVN r11506
|
A Worker Thread class. More...
Public Member Functions | |
cbWorkerThread (cbThreadPool *pool, CountedPtr< wxSemaphore > &semaphore) | |
cbWorkerThread ctor More... | |
ExitCode | Entry () override |
Entry point of this thread. The magic happens here. More... | |
void | Abort () |
Tell the thread to abort. It will also tell the task to abort (if any) More... | |
bool | Aborted () const |
Tells whether we should abort or not. More... | |
void | AbortTask () |
Aborts the running task (if any) More... | |
Public Member Functions inherited from wxThread | |
wxThread (wxThreadKind kind=wxTHREAD_DETACHED) | |
virtual | ~wxThread () |
wxThreadError | Create (unsigned int stackSize=0) |
wxThreadError | Delete (ExitCode *rc=NULL, wxThreadWait waitMode=wxTHREAD_WAIT_BLOCK) |
wxThreadIdType | GetId () const |
wxThreadKind | GetKind () const |
unsigned int | GetPriority () const |
bool | IsAlive () const |
bool | IsDetached () const |
bool | IsPaused () const |
bool | IsRunning () const |
wxThreadError | Kill () |
wxThreadError | Pause () |
wxThreadError | Resume () |
wxThreadError | Run () |
void | SetPriority (unsigned int priority) |
virtual bool | TestDestroy () |
ExitCode | Wait (wxThreadWait flags=wxTHREAD_WAIT_BLOCK) |
Private Attributes | |
bool | m_abort |
whether is is aborted or not More... | |
cbThreadPool * | m_pPool |
point to the pool which the thread belong to More... | |
CountedPtr< wxSemaphore > | m_semaphore |
a pointer to the wxSemaphore it is a counted semaphore pointer shared with all the cbWorkerThread More... | |
cbThreadedTask * | m_pTask |
a pointer to the running task More... | |
wxMutex | m_taskMutex |
to protect the member variable accessing from multiply threads lock the access to the m_pTask cbWorkerThread::AbortTask() which access to m_pTask may be called from poll when thread is running More... | |
Additional Inherited Members | |
Public Types inherited from wxThread | |
typedef void * | ExitCode |
Static Public Member Functions inherited from wxThread | |
static int | GetCPUCount () |
static wxThreadIdType | GetCurrentId () |
static wxThreadIdType | GetMainId () |
static bool | IsMain () |
static bool | SetConcurrency (size_t level) |
static void | Sleep (unsigned long milliseconds) |
static wxThread * | This () |
static void | Yield () |
Protected Member Functions inherited from wxThread | |
void | Exit (ExitCode exitcode=0) |
A Worker Thread class.
These are the ones that execute the tasks. You shouldn't worry about it since it's for "private" purposes of the Pool.
Definition at line 158 of file cbthreadpool.h.
cbThreadPool::cbWorkerThread::cbWorkerThread | ( | cbThreadPool * | pool, |
CountedPtr< wxSemaphore > & | semaphore | ||
) |
cbWorkerThread ctor
pool | Thread Pool this Worker Thread belongs to |
semaphore | Used to synchronize the Worker Threads, it is a reference to the CountedPtr object |
Definition at line 173 of file cbthreadpool.cpp.
void cbThreadPool::cbWorkerThread::Abort | ( | ) |
Tell the thread to abort. It will also tell the task to abort (if any)
Definition at line 246 of file cbthreadpool.cpp.
References AbortTask(), and m_abort.
Referenced by cbThreadPool::_SetConcurrentThreads(), and cbThreadPool::~cbThreadPool().
bool cbThreadPool::cbWorkerThread::Aborted | ( | ) | const |
Tells whether we should abort or not.
Definition at line 252 of file cbthreadpool.cpp.
References m_abort.
Referenced by Entry().
void cbThreadPool::cbWorkerThread::AbortTask | ( | ) |
Aborts the running task (if any)
Definition at line 257 of file cbthreadpool.cpp.
References cbThreadedTask::Abort(), m_pTask, and m_taskMutex.
Referenced by Abort(), and cbThreadPool::AbortAllTasks().
|
overridevirtual |
Entry point of this thread. The magic happens here.
Implements wxThread.
Definition at line 182 of file cbthreadpool.cpp.
References Aborted(), cbThreadPool::cbThreadedTaskElement::Delete(), cbThreadedTask::Execute(), cbThreadPool::GetNextTask(), m_pPool, m_pTask, m_semaphore, m_taskMutex, cbThreadPool::cbThreadedTaskElement::task, cbThreadPool::TaskDone(), wxSemaphore::Wait(), cbThreadPool::WaitingThread(), and cbThreadPool::WorkingThread().
|
private |
whether is is aborted or not
Definition at line 186 of file cbthreadpool.h.
|
private |
point to the pool which the thread belong to
Definition at line 189 of file cbthreadpool.h.
Referenced by Entry().
|
private |
a pointer to the running task
Definition at line 197 of file cbthreadpool.h.
Referenced by AbortTask(), and Entry().
|
private |
a pointer to the wxSemaphore it is a counted semaphore pointer shared with all the cbWorkerThread
Definition at line 194 of file cbthreadpool.h.
Referenced by Entry().
|
private |
to protect the member variable accessing from multiply threads lock the access to the m_pTask cbWorkerThread::AbortTask() which access to m_pTask may be called from poll when thread is running
Definition at line 204 of file cbthreadpool.h.
Referenced by AbortTask(), and Entry().