18 #ifndef ION_BASE_WORKERPOOL_H_
19 #define ION_BASE_WORKERPOOL_H_
67 virtual const std::string&
GetName()
const = 0;
107 void KillAllThreads();
113 Worker*
const worker_;
117 std::atomic<bool> suspended_;
120 std::atomic<bool> killing_;
125 std::atomic<bool> slow_path_;
126 std::function<bool()> spawn_func_;
135 #endif // ION_BASE_WORKERPOOL_H_
Interface to enable pluggable worker behavior.
A Semaphore enables threads and process synchronization.
Manages one or more threads that run in a loop, performing some work with each iteration (if any work...
Allocatable is an abstract base class for classes whose memory is managed by an Allocator.
void ResizeThreadPool(size_t thread_count)
Changes the number of theads in the pool.
virtual ~Worker()
Virtual classes need virtual desructors.
void Suspend()
Suspends all threads until Resume() is called.
void Resume()
Resumes all threads.
WorkerPool(Worker *worker)
Constructor/destructor.
bool IsSuspended() const
Return true if pool's threads are suspended.
port::Semaphore * GetWorkSemaphore()
Returns the semaphore that is used to signal that a unit of work is available to process.
virtual void DoWork()=0
Called repeatedly in worker thread loop, whenever GetWorkSemaphore() is signaled to indicate that the...
const std::string & GetName() const
Gets a descriptive name for the pool from the worker.
A Mutex is used to ensure that only one thread or process can access a block of code at one time...
virtual void ThreadEntryPoint()
ThreadEntryPoint() is run on each created thread.
virtual const std::string & GetName() const =0
Return the worker's name.