Ion
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
ion::base::WorkerPool::Worker Class Referenceabstract

Interface to enable pluggable worker behavior. More...

#include "workerpool.h"

Public Member Functions

virtual void DoWork ()=0
 Called repeatedly in worker thread loop, whenever GetWorkSemaphore() is signaled to indicate that there is work to do. More...
 
virtual const std::string & GetName () const =0
 Return the worker's name. More...
 

Protected Member Functions

virtual ~Worker ()
 Virtual classes need virtual desructors. More...
 

Detailed Description

Interface to enable pluggable worker behavior.

One of the WorkerPool threads will invoke Worker::DoWork() when there is work available to do (i.e. when someone calls GetWorkSemaphore()->Post()).

Definition at line 51 of file workerpool.h.

Constructor & Destructor Documentation

virtual ion::base::WorkerPool::Worker::~Worker ( )
inlineprotectedvirtual

Virtual classes need virtual desructors.

Definition at line 71 of file workerpool.h.

Member Function Documentation

virtual void ion::base::WorkerPool::Worker::DoWork ( )
pure virtual

Called repeatedly in worker thread loop, whenever GetWorkSemaphore() is signaled to indicate that there is work to do.

Note
the WorkerPool implementation occasionally signals the semaphore during state changes (e.g., adding/removing threads, and when suspending or resuming); subclasses of Worker must handle this gracefully. However, there won't be many of these "extra" signals, so DoWork() can simply return as soon as it realizes there is no work to do. In particular, Worker subclasses should not try to proactively limit CPU use, e.g. by sleeping for a few milliseconds when no work is available.
virtual const std::string& ion::base::WorkerPool::Worker::GetName ( ) const
pure virtual

Return the worker's name.

Referenced by ion::base::WorkerPool::GetName().


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