Dash Core Source Documentation (0.16.0.1)
Find detailed information regarding the Dash Core source code.
Queue for verifications that have to be performed. More...
#include <checkqueue.h>
Public Member Functions | |
CCheckQueue (unsigned int nBatchSizeIn) | |
Create a new check queue. More... | |
void | Thread () |
Worker thread. More... | |
bool | Wait () |
Wait until execution finishes, and return whether all evaluations were successful. More... | |
void | Add (std::vector< T > &vChecks) |
Add a batch of checks to the queue. More... | |
~CCheckQueue () | |
Public Attributes | |
boost::mutex | ControlMutex |
Mutex to ensure only one concurrent CCheckQueueControl. More... | |
Private Member Functions | |
bool | Loop (bool fMaster=false) |
Internal function that does bulk of the verification work. More... | |
Private Attributes | |
boost::mutex | mutex |
Mutex to protect the inner state. More... | |
boost::condition_variable | condWorker |
Worker threads block on this when out of work. More... | |
boost::condition_variable | condMaster |
Master thread blocks on this when out of work. More... | |
std::vector< T > | queue |
The queue of elements to be processed. More... | |
int | nIdle |
The number of workers (including the master) that are idle. More... | |
int | nTotal |
The total number of workers (including the master). More... | |
bool | fAllOk |
The temporary evaluation result. More... | |
unsigned int | nTodo |
Number of verifications that haven't completed yet. More... | |
unsigned int | nBatchSize |
The maximum number of elements to be processed in one batch. More... | |
Detailed Description
template<typename T>
class CCheckQueue< T >
Queue for verifications that have to be performed.
The verifications are represented by a type T, which must provide an operator(), returning a bool.
One thread (the master) is assumed to push batches of verifications onto the queue, where they are processed by N-1 worker threads. When the master is done adding work, it temporarily joins the worker pool as an N'th worker, until all jobs are done.
Definition at line 30 of file checkqueue.h.
Constructor & Destructor Documentation
◆ CCheckQueue()
|
inlineexplicit |
Create a new check queue.
Definition at line 131 of file checkqueue.h.
◆ ~CCheckQueue()
|
inline |
Definition at line 160 of file checkqueue.h.
Member Function Documentation
◆ Add()
|
inline |
Add a batch of checks to the queue.
Definition at line 146 of file checkqueue.h.
References CCheckQueue< T >::condWorker, CCheckQueue< T >::mutex, CCheckQueue< T >::nTodo, and CCheckQueue< T >::queue.
◆ Loop()
|
inlineprivate |
Internal function that does bulk of the verification work.
Definition at line 66 of file checkqueue.h.
References CCheckQueue< T >::condMaster, CCheckQueue< T >::condWorker, CCheckQueue< T >::fAllOk, CCheckQueue< T >::mutex, CCheckQueue< T >::nBatchSize, CCheckQueue< T >::nIdle, CCheckQueue< T >::nTodo, CCheckQueue< T >::nTotal, and CCheckQueue< T >::queue.
Referenced by CCheckQueue< T >::Thread(), and CCheckQueue< T >::Wait().
◆ Thread()
|
inline |
◆ Wait()
|
inline |
Wait until execution finishes, and return whether all evaluations were successful.
Definition at line 140 of file checkqueue.h.
References CCheckQueue< T >::Loop().
Member Data Documentation
◆ condMaster
|
private |
Master thread blocks on this when out of work.
Definition at line 40 of file checkqueue.h.
Referenced by CCheckQueue< T >::Loop().
◆ condWorker
|
private |
Worker threads block on this when out of work.
Definition at line 37 of file checkqueue.h.
Referenced by CCheckQueue< T >::Add(), and CCheckQueue< T >::Loop().
◆ ControlMutex
boost::mutex CCheckQueue< T >::ControlMutex |
Mutex to ensure only one concurrent CCheckQueueControl.
Definition at line 128 of file checkqueue.h.
◆ fAllOk
|
private |
The temporary evaluation result.
Definition at line 53 of file checkqueue.h.
Referenced by CCheckQueue< T >::Loop().
◆ mutex
|
private |
Mutex to protect the inner state.
Definition at line 34 of file checkqueue.h.
Referenced by CCheckQueue< T >::Add(), and CCheckQueue< T >::Loop().
◆ nBatchSize
|
private |
The maximum number of elements to be processed in one batch.
Definition at line 63 of file checkqueue.h.
Referenced by CCheckQueue< T >::Loop().
◆ nIdle
|
private |
The number of workers (including the master) that are idle.
Definition at line 47 of file checkqueue.h.
Referenced by CCheckQueue< T >::Loop().
◆ nTodo
|
private |
Number of verifications that haven't completed yet.
This includes elements that are no longer queued, but still in the worker's own batches.
Definition at line 60 of file checkqueue.h.
Referenced by CCheckQueue< T >::Add(), and CCheckQueue< T >::Loop().
◆ nTotal
|
private |
The total number of workers (including the master).
Definition at line 50 of file checkqueue.h.
Referenced by CCheckQueue< T >::Loop().
◆ queue
|
private |
The queue of elements to be processed.
As the order of booleans doesn't matter, it is used as a LIFO (stack)
Definition at line 44 of file checkqueue.h.
Referenced by CCheckQueue< T >::Add(), and CCheckQueue< T >::Loop().
The documentation for this class was generated from the following file:
- src/checkqueue.h