Code::Blocks  SVN r11506
Public Member Functions | Private Attributes | List of all members
cbThreadPool::cbWorkerThread Class Reference

A Worker Thread class. More...

Inheritance diagram for cbThreadPool::cbWorkerThread:
Collaboration diagram for cbThreadPool::cbWorkerThread:

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...
 
cbThreadPoolm_pPool
 point to the pool which the thread belong to More...
 
CountedPtr< wxSemaphorem_semaphore
 a pointer to the wxSemaphore it is a counted semaphore pointer shared with all the cbWorkerThread More...
 
cbThreadedTaskm_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 wxThreadThis ()
 
static void Yield ()
 
- Protected Member Functions inherited from wxThread
void Exit (ExitCode exitcode=0)
 

Detailed Description

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.

Constructor & Destructor Documentation

◆ cbWorkerThread()

cbThreadPool::cbWorkerThread::cbWorkerThread ( cbThreadPool pool,
CountedPtr< wxSemaphore > &  semaphore 
)

cbWorkerThread ctor

Parameters
poolThread Pool this Worker Thread belongs to
semaphoreUsed to synchronize the Worker Threads, it is a reference to the CountedPtr object

Definition at line 173 of file cbthreadpool.cpp.

Member Function Documentation

◆ Abort()

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().

◆ Aborted()

bool cbThreadPool::cbWorkerThread::Aborted ( ) const

Tells whether we should abort or not.

Returns
true if we should abort

Definition at line 252 of file cbthreadpool.cpp.

References m_abort.

Referenced by Entry().

◆ AbortTask()

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().

◆ Entry()

wxThread::ExitCode cbThreadPool::cbWorkerThread::Entry ( )
overridevirtual

Member Data Documentation

◆ m_abort

bool cbThreadPool::cbWorkerThread::m_abort
private

whether is is aborted or not

Definition at line 186 of file cbthreadpool.h.

Referenced by Abort(), and Aborted().

◆ m_pPool

cbThreadPool* cbThreadPool::cbWorkerThread::m_pPool
private

point to the pool which the thread belong to

Definition at line 189 of file cbthreadpool.h.

Referenced by Entry().

◆ m_pTask

cbThreadedTask* cbThreadPool::cbWorkerThread::m_pTask
private

a pointer to the running task

Definition at line 197 of file cbthreadpool.h.

Referenced by AbortTask(), and Entry().

◆ m_semaphore

CountedPtr<wxSemaphore> cbThreadPool::cbWorkerThread::m_semaphore
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().

◆ m_taskMutex

wxMutex cbThreadPool::cbWorkerThread::m_taskMutex
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().


The documentation for this class was generated from the following files: