Honeycomb  0.1
Component-Model Framework
Classes | Public Member Functions | Static Public Member Functions | List of all members
honey::thread::Pool Class Reference

Spreads task execution across a pool of re-usable threads. Uses a lock-free work-stealing queue to ensure workers are never idle. More...

#include <Pool.h>

Inheritance diagram for honey::thread::Pool:
Inheritance graph
[legend]
Collaboration diagram for honey::thread::Pool:
Collaboration graph
[legend]

Classes

struct  Task
 All tasks must inherit from this class. std::function is not used here to avoid the operator() virtual call. More...
 

Public Member Functions

 Pool (szt workerCount, szt workerTaskMax)
 
 ~Pool ()
 
template<class Task >
void enqueue (Task &&task)
 Schedule a task for execution. More...
 
- Public Member Functions inherited from honey::SharedObj< Pool >
 SharedObj (Alloc &&a=Alloc()) debug_if(
 Construct with allocator that is called to deallocate this shared object when all references have been released. More...
 

Static Public Member Functions

static Task * current ()
 Get the current task object of the calling thread. Must be called from inside a task, returns null otherwise. More...
 

Additional Inherited Members

- Protected Member Functions inherited from honey::SharedObj< Pool >
void finalize ()
 Destroys object. Called when strong reference count reaches 0. May be overridden to prevent destruction. More...
 

Detailed Description

Spreads task execution across a pool of re-usable threads. Uses a lock-free work-stealing queue to ensure workers are never idle.

Constructor & Destructor Documentation

honey::thread::Pool::Pool ( szt  workerCount,
szt  workerTaskMax 
)
Parameters
workerCountNumber of workers
workerTaskMaxMax size of per-worker task queue, overflow will be pushed onto pool queue
honey::thread::Pool::~Pool ( )

Member Function Documentation

static Task* honey::thread::Pool::current ( )
inlinestatic

Get the current task object of the calling thread. Must be called from inside a task, returns null otherwise.

template<class Task >
void honey::thread::Pool::enqueue ( Task &&  task)
inline

Schedule a task for execution.


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