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

Description:

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

Definition at line 19 of file threadpool.inl.

Inheritance diagram for alib::threadmodel::PoolWorker:
alib::threads::Thread alib::threads::Runnable

Public Field Index:

String64 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 ThreadGet (std::thread::id nativeID)
static ThreadGetCurrent ()
static 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
void destruct ()
 Thread (const character *pName=A_CHAR(""))
 Thread (const Thread &)=delete
 Deleted copy constructor.
 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 void Join ()
virtual void SetName (const character *newName)
virtual void Start ()
Protected Method Index: inherited from alib::threads::Runnable
virtual ~Runnable ()
 Virtual destructor.

Field Details:

◆ nameBuffer

String64 alib::threadmodel::PoolWorker::nameBuffer

Buffer to store the thread name given with construction.

Definition at line 26 of file threadpool.inl.

◆ threadPool

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

The pool that this instance belongs to.

Definition at line 23 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 31 of file threadpool.inl.

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 47 of file threadpool.inl.

◆ Run()

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

Implementation of virtual void Run() override. Retrieves jobs from the pool, invokes PrepareJob, and then calls virtual bool Do() .

Reimplemented from alib::threads::Thread.


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