Bitcoin ABC 0.26.3
P2P Digital Currency
Loading...
Searching...
No Matches
Public Member Functions | Private Attributes | List of all members
WorkQueue< WorkItem > Class Template Reference

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

Collaboration diagram for WorkQueue< WorkItem >:
[legend]

Public Member Functions

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

Private Attributes

Mutex cs
 Mutex protects entire object.
 
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 73 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 all been joined)

Definition at line 87 of file httpserver.cpp.

Member Function Documentation

◆ Enqueue()

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

Enqueue a work item.

Definition at line 90 of file httpserver.cpp.

◆ Interrupt()

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

Interrupt and exit loops.

Definition at line 120 of file httpserver.cpp.

◆ Run()

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

Thread function.

Definition at line 101 of file httpserver.cpp.

Here is the caller graph for this function:

Member Data Documentation

◆ cond

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

Definition at line 77 of file httpserver.cpp.

◆ cs

template<typename WorkItem >
Mutex WorkQueue< WorkItem >::cs
private

Mutex protects entire object.

Definition at line 76 of file httpserver.cpp.

◆ maxDepth

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

Definition at line 80 of file httpserver.cpp.

◆ queue

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

Definition at line 78 of file httpserver.cpp.

◆ running

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

Definition at line 79 of file httpserver.cpp.


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