ALib C++ Library
Library Version: 2511 R0
Documentation generated by doxygen
Loading...
Searching...
No Matches
alib::threadmodel::PoolWorker Struct Reference

Description:

Attention
This class belongs to module ALib ThreadModel, which is not in a stable and consistent state, yet. Also, this type is considered experimental.

Instances of this thread-class are created by ThreadPools. Applications may extend this class and override method PrepareJob.

Definition at line 25 of file threadpool.inl.

Inheritance diagram for alib::threadmodel::PoolWorker:
[legend]
Collaboration diagram for alib::threadmodel::PoolWorker:
[legend]

Public Field Index:

String16 nameBuffer
 Buffer to store the thread name given with construction.
 
ThreadPoolthreadPool
 The pool that this instance belongs to.
 

Public Method Index:

 PoolWorker (ThreadPool &pThreadPool, const character *threadName)
 
virtual void PrepareJob (Job *job)
 
void Run () override
 

Additional Inherited Members

- Protected Type Index: inherited from alib::threads::Thread
enum class  State {
  Unstarted = 0 , Started = 1 , Running = 2 , Done = 3 ,
  Terminated = 4
}
 
- Protected Static Method Index: inherited from alib::threads::Thread
static ALIB_DLL ThreadGet (std::thread::id nativeID)
 
static ThreadGetCurrent ()
 
static ALIB_DLL ThreadGetMain ()
 
static void Sleep (const Ticks::Duration &duration)
 
static void Sleep (const Ticks::Duration::TDuration &duration)
 
static void SleepMicros (int64_t microseconds)
 
static void SleepMillis (int milliseconds)
 
static void SleepNanos (int64_t nanoseconds)
 
static void SleepUntil (const Ticks &time)
 
static void YieldToSystem ()
 
- Protected Field Index: inherited from alib::threads::Thread
std::thread * c11Thread =nullptr
 The internal C++ thread object.
 
ThreadID id =0
 The id of the thread.
 
const charactername =nullptr
 The name of the thread.
 
std::thread::id nativeID
 The internal C++ thread id.
 
Runnablerunnable =nullptr
 The runnable to execute.
 
State state = State::Unstarted
 Internal flag to indicate if the thread is alive.
 
- Protected Method Index: inherited from alib::threads::Thread
ALIB_DLL void destruct ()
 
 Thread (const character *pName=A_CHAR(""))
 
 Thread (const Thread &)=delete
 Deleted copy constructor.
 
ALIB_DLL Thread (Runnable *target, const character *pName=A_CHAR(""))
 
virtual ~Thread () override
 
ThreadID GetID () const
 
virtual const characterGetName () const
 
std::thread::id GetNativeID () const
 
State GetState ()
 
bool IsAlive ()
 
virtual ALIB_DLL void Join ()
 
virtual void SetName (const character *newName)
 
virtual ALIB_DLL void Start ()
 
- Protected Method Index: inherited from alib::threads::Runnable
virtual ~Runnable ()
 Virtual destructor.
 

Friends And Related Entity Details:

◆ ThreadPool

friend class ThreadPool
friend

Type alias in namespace alib.

Definition at line 26 of file threadpool.inl.

Field Details:

◆ nameBuffer

String16 alib::threadmodel::PoolWorker::nameBuffer

Buffer to store the thread name given with construction.

Definition at line 30 of file threadpool.inl.

◆ threadPool

ThreadPool& alib::threadmodel::PoolWorker::threadPool

The pool that this instance belongs to.

Definition at line 27 of file threadpool.inl.

Constructor(s) / Destructor Details:

◆ PoolWorker()

alib::threadmodel::PoolWorker::PoolWorker ( ThreadPool & pThreadPool,
const character * threadName )
inline

Constructor.

Parameters
pThreadPoolThe pool that constructed us.
threadNameThe name of this thread (for logging and diagnosis)

Definition at line 35 of file threadpool.inl.

Here is the call graph for this function:

Method Details:

◆ PrepareJob()

virtual void alib::threadmodel::PoolWorker::PrepareJob ( Job * job)
inlinevirtual

This default implementation does nothing. Derived types may dynamically cast the parameter job to a known custom type and, for example, attach custom data found in a derived version of this class.

Parameters
jobThe job to prepare.

Definition at line 51 of file threadpool.inl.

◆ Run()

void alib::threadmodel::PoolWorker::Run ( )
overridevirtual

Implementation of Thread::Run. Retrieves jobs from the pool, invokes PrepareJob, and then calls Job::Do.

Reimplemented from alib::threads::Thread.


The documentation for this struct was generated from the following file: