iLab Neuromorphic Robotics Toolkit  0.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
nrt::BoundedLocalQueueThreadPool Class Reference

#include <nrt/Core/Design/ThreadPools.H>

A bounded thread pool with thread local work queues.

This thread pool consists of some fixed number of threads which attempt to get jobs from a work queue, sleeping while they have no work to do.

Each thread will first attempt to use its own work queue for jobs before looking in a shared work queue amongst all jobs. Threads will also attempt to steal jobs from other thread local job queues if they have no work to do.

Based off of an implementation in C++ Concurrency in Action: Practical Multithreading by Anthony Williams

Definition at line 93 of file ThreadPools.H.

Public Member Functions

 BoundedLocalQueueThreadPool (size_t const numThreads=std::thread::hardware_concurrency())
template<class Func >
std::future< typename
std::result_of< Func()>::type > 
pushJob (Func f)
void runPendingTask ()

Protected Member Functions

void workerThread (size_t index)
bool popTaskFromLocalQueue (FunctionWrapper &task)
bool popTaskFromPoolQueue (FunctionWrapper &task)
bool popTaskFromOtherThreadQueue (FunctionWrapper &task)

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