Dash Core Source Documentation (0.16.0.1)
Find detailed information regarding the Dash Core source code.
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()
Definition at line 83 of file httpserver.cpp.
◆ ~WorkQueue()
Precondition: worker threads have all stopped (they have been joined).
Definition at line 89 of file httpserver.cpp.
Member Function Documentation
◆ Enqueue()
|
inline |
Enqueue a work item.
Definition at line 93 of file httpserver.cpp.
References WorkQueue< WorkItem >::cond, WorkQueue< WorkItem >::cs, WorkQueue< WorkItem >::maxDepth, and WorkQueue< WorkItem >::queue.
◆ 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()
|
inline |
Thread function.
Definition at line 104 of file httpserver.cpp.
References WorkQueue< WorkItem >::cond, WorkQueue< WorkItem >::cs, WorkQueue< WorkItem >::queue, and WorkQueue< WorkItem >::running.
Referenced by HTTPWorkQueueRun().
Member Data Documentation
◆ cond
|
private |
Definition at line 77 of file httpserver.cpp.
Referenced by WorkQueue< WorkItem >::Enqueue(), WorkQueue< WorkItem >::Interrupt(), and WorkQueue< WorkItem >::Run().
◆ 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
|
private |
Definition at line 80 of file httpserver.cpp.
Referenced by WorkQueue< WorkItem >::Enqueue().
◆ queue
|
private |
Definition at line 78 of file httpserver.cpp.
Referenced by WorkQueue< WorkItem >::Enqueue(), and WorkQueue< WorkItem >::Run().
◆ 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:
- src/httpserver.cpp