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

◆ ~WorkStealingThreadPool()

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

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 WorkStealingThreadPool< CONTEXT >::myQueueIndex, WorkStealingThreadPool< CONTEXT >::myQueues, and WorkStealingThreadPool< CONTEXT >::myTryoutCount.

Referenced by WorkStealingThreadPool< CONTEXT >::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 WorkStealingThreadPool< CONTEXT >::myQueues.

Referenced by WorkStealingThreadPool< CONTEXT >::WorkStealingThreadPool().

Here is the caller graph for this function:

◆ waitAll()

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

◆ 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 WorkStealingThreadPool< CONTEXT >::myQueues, and WorkStealingThreadPool< CONTEXT >::myTryoutCount.

Referenced by WorkStealingThreadPool< CONTEXT >::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

◆ myQueues

◆ myThreads

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

◆ myTryoutCount

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

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