Dash Core Source Documentation (0.16.0.1)

Find detailed information regarding the Dash Core source code.

WorkQueue< WorkItem > Class Template Reference

Simple work queue for distributing work over multiple threads. More...

Public Member Functions

 WorkQueue (size_t _maxDepth)
 
 ~WorkQueue ()
 Precondition: worker threads have all stopped (they have been joined). More...
 
bool Enqueue (WorkItem *item)
 Enqueue a work item. More...
 
void Run ()
 Thread function. More...
 
void Interrupt ()
 Interrupt and exit loops. More...
 

Private Attributes

std::mutex cs
 Mutex protects entire object. More...
 
std::condition_variable cond
 
std::deque< std::unique_ptr< WorkItem > > queue
 
bool running
 
size_t maxDepth
 

Detailed Description

template<typename WorkItem>
class WorkQueue< WorkItem >

Simple work queue for distributing work over multiple threads.

Work items are simply callable objects.

Definition at line 72 of file httpserver.cpp.

Constructor & Destructor Documentation

◆ WorkQueue()

template<typename WorkItem>
WorkQueue< WorkItem >::WorkQueue ( size_t  _maxDepth)
inlineexplicit

Definition at line 83 of file httpserver.cpp.

◆ ~WorkQueue()

template<typename WorkItem>
WorkQueue< WorkItem >::~WorkQueue ( )
inline

Precondition: worker threads have all stopped (they have been joined).

Definition at line 89 of file httpserver.cpp.

Member Function Documentation

◆ Enqueue()

template<typename WorkItem>
bool WorkQueue< WorkItem >::Enqueue ( WorkItem *  item)
inline

◆ Interrupt()

template<typename WorkItem>
void WorkQueue< WorkItem >::Interrupt ( )
inline

Interrupt and exit loops.

Definition at line 121 of file httpserver.cpp.

References WorkQueue< WorkItem >::cond, WorkQueue< WorkItem >::cs, and WorkQueue< WorkItem >::running.

◆ Run()

template<typename WorkItem>
void WorkQueue< WorkItem >::Run ( )
inline

Member Data Documentation

◆ cond

template<typename WorkItem>
std::condition_variable WorkQueue< WorkItem >::cond
private

◆ cs

template<typename WorkItem>
std::mutex WorkQueue< WorkItem >::cs
private

Mutex protects entire object.

Definition at line 76 of file httpserver.cpp.

Referenced by WorkQueue< WorkItem >::Enqueue(), WorkQueue< WorkItem >::Interrupt(), and WorkQueue< WorkItem >::Run().

◆ maxDepth

template<typename WorkItem>
size_t WorkQueue< WorkItem >::maxDepth
private

Definition at line 80 of file httpserver.cpp.

Referenced by WorkQueue< WorkItem >::Enqueue().

◆ queue

template<typename WorkItem>
std::deque<std::unique_ptr<WorkItem> > WorkQueue< WorkItem >::queue
private

Definition at line 78 of file httpserver.cpp.

Referenced by WorkQueue< WorkItem >::Enqueue(), and WorkQueue< WorkItem >::Run().

◆ running

template<typename WorkItem>
bool WorkQueue< WorkItem >::running
private

Definition at line 79 of file httpserver.cpp.

Referenced by WorkQueue< WorkItem >::Interrupt(), and WorkQueue< WorkItem >::Run().


The documentation for this class was generated from the following file:
Released under the MIT license