![]() |
PRCYCoin
2.0.0.7rc1
P2P Digital Currency
|
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 where successful. More... | |
| void | Add (std::vector< T > &vChecks) |
| Add a batch of checks to the queue. More... | |
| ~CCheckQueue () | |
| bool | IsIdle () |
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... | |
| bool | fQuit |
| Whether we're shutting down. More... | |
| unsigned int | nBatchSize |
| The maximum number of elements to be processed in one batch. More... | |
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 29 of file checkqueue.h.
|
inline |
Create a new check queue.
Definition at line 130 of file checkqueue.h.
|
inline |
Definition at line 159 of file checkqueue.h.
|
inline |
Add a batch of checks to the queue.
Definition at line 145 of file checkqueue.h.
|
inline |
Definition at line 163 of file checkqueue.h.
|
inlineprivate |
Internal function that does bulk of the verification work.
Definition at line 68 of file checkqueue.h.
|
inline |
Worker thread.
Definition at line 133 of file checkqueue.h.
|
inline |
Wait until execution finishes, and return whether all evaluations where successful.
Definition at line 139 of file checkqueue.h.
|
private |
Master thread blocks on this when out of work.
Definition at line 39 of file checkqueue.h.
|
private |
Worker threads block on this when out of work.
Definition at line 36 of file checkqueue.h.
|
private |
The temporary evaluation result.
Definition at line 52 of file checkqueue.h.
|
private |
Whether we're shutting down.
Definition at line 62 of file checkqueue.h.
|
private |
Mutex to protect the inner state.
Definition at line 33 of file checkqueue.h.
|
private |
The maximum number of elements to be processed in one batch.
Definition at line 65 of file checkqueue.h.
|
private |
The number of workers (including the master) that are idle.
Definition at line 46 of file checkqueue.h.
|
private |
Number of verifications that haven't completed yet.
This includes elements that are not anymore in queue, but still in worker's own batches.
Definition at line 59 of file checkqueue.h.
|
private |
The total number of workers (including the master).
Definition at line 49 of file checkqueue.h.
|
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 43 of file checkqueue.h.
1.8.17