Eclipse SUMO - Simulation of Urban MObility
Loading...
Searching...
No Matches
WorkStealingThreadPool< CONTEXT > Class Template Reference

#include <WorkStealingThreadPool.h>

Public Member Functions

template<typename TaskT>
auto executeAsync (TaskT &&task, int idx=-1) -> std::future< decltype(task(std::declval< CONTEXT >()))>
void waitAll ()
 WorkStealingThreadPool (const bool workSteal, const std::vector< CONTEXT > &context)
 ~WorkStealingThreadPool ()

Private Member Functions

void run (size_t queueIndex, const CONTEXT &context)
void workStealRun (size_t queueIndex, const CONTEXT &context)

Private Attributes

std::atomic< size_t > myQueueIndex { 0 }
std::vector< TaskQueue< CONTEXT > > myQueues
std::vector< std::thread > myThreads
const size_t myTryoutCount

Detailed Description

template<typename CONTEXT = int>
class WorkStealingThreadPool< CONTEXT >

Definition at line 30 of file WorkStealingThreadPool.h.

Constructor & Destructor Documentation

◆ WorkStealingThreadPool()

template<typename CONTEXT = int>
WorkStealingThreadPool< CONTEXT >::WorkStealingThreadPool ( const bool workSteal,
const std::vector< CONTEXT > & context )
inlineexplicit

Definition at line 33 of file WorkStealingThreadPool.h.

References myQueues, myThreads, myTryoutCount, run(), and workStealRun().

◆ ~WorkStealingThreadPool()

template<typename CONTEXT = int>
WorkStealingThreadPool< CONTEXT >::~WorkStealingThreadPool ( )
inline

Definition at line 46 of file WorkStealingThreadPool.h.

References myQueues, and myThreads.

Member Function Documentation

◆ executeAsync()

template<typename CONTEXT = int>
template<typename TaskT>
auto WorkStealingThreadPool< CONTEXT >::executeAsync ( TaskT && task,
int idx = -1 )->std::future< decltype(task(std::declval< CONTEXT >()))>
inline

Definition at line 56 of file WorkStealingThreadPool.h.

References myQueueIndex, myQueues, myTryoutCount, and n.

Referenced by waitAll().

Here is the caller graph for this function:

◆ run()

template<typename CONTEXT = int>
void WorkStealingThreadPool< CONTEXT >::run ( size_t queueIndex,
const CONTEXT & context )
inlineprivate

Definition at line 86 of file WorkStealingThreadPool.h.

References myQueues.

Referenced by WorkStealingThreadPool().

Here is the caller graph for this function:

◆ waitAll()

template<typename CONTEXT = int>
void WorkStealingThreadPool< CONTEXT >::waitAll ( )
inline

Definition at line 75 of file WorkStealingThreadPool.h.

References executeAsync(), myQueues, and n.

◆ workStealRun()

template<typename CONTEXT = int>
void WorkStealingThreadPool< CONTEXT >::workStealRun ( size_t queueIndex,
const CONTEXT & context )
inlineprivate

Definition at line 95 of file WorkStealingThreadPool.h.

References myQueues, myTryoutCount, and n.

Referenced by WorkStealingThreadPool().

Here is the caller graph for this function:

Field Documentation

◆ myQueueIndex

template<typename CONTEXT = int>
std::atomic<size_t> WorkStealingThreadPool< CONTEXT >::myQueueIndex { 0 }
private

Definition at line 112 of file WorkStealingThreadPool.h.

Referenced by executeAsync().

◆ myQueues

template<typename CONTEXT = int>
std::vector<TaskQueue<CONTEXT> > WorkStealingThreadPool< CONTEXT >::myQueues
private

◆ myThreads

template<typename CONTEXT = int>
std::vector<std::thread> WorkStealingThreadPool< CONTEXT >::myThreads
private

Definition at line 114 of file WorkStealingThreadPool.h.

Referenced by WorkStealingThreadPool(), and ~WorkStealingThreadPool().

◆ myTryoutCount

template<typename CONTEXT = int>
const size_t WorkStealingThreadPool< CONTEXT >::myTryoutCount
private

Definition at line 113 of file WorkStealingThreadPool.h.

Referenced by executeAsync(), WorkStealingThreadPool(), and workStealRun().


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