aboutsummaryrefslogtreecommitdiff
path: root/src/checkqueue.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/checkqueue.h')
-rw-r--r--src/checkqueue.h50
1 files changed, 27 insertions, 23 deletions
diff --git a/src/checkqueue.h b/src/checkqueue.h
index afecfeede5..2ee46a1210 100644
--- a/src/checkqueue.h
+++ b/src/checkqueue.h
@@ -1,5 +1,5 @@
-// Copyright (c) 2012 The Bitcoin developers
-// Distributed under the MIT/X11 software license, see the accompanying
+// Copyright (c) 2012-2014 The Bitcoin developers
+// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#ifndef BITCOIN_CHECKQUEUE_H
@@ -16,7 +16,8 @@
template <typename T>
class CCheckQueueControl;
-/** Queue for verifications that have to be performed.
+/**
+ * Queue for verifications that have to be performed.
* The verifications are represented by a type T, which must provide an
* operator(), returning a bool.
*
@@ -29,40 +30,42 @@ template <typename T>
class CCheckQueue
{
private:
- // Mutex to protect the inner state
+ //! Mutex to protect the inner state
boost::mutex mutex;
- // Worker threads block on this when out of work
+ //! Worker threads block on this when out of work
boost::condition_variable condWorker;
- // Master thread blocks on this when out of work
+ //! Master thread blocks on this when out of work
boost::condition_variable condMaster;
- // The queue of elements to be processed.
- // As the order of booleans doesn't matter, it is used as a LIFO (stack)
+ //! The queue of elements to be processed.
+ //! As the order of booleans doesn't matter, it is used as a LIFO (stack)
std::vector<T> queue;
- // The number of workers (including the master) that are idle.
+ //! The number of workers (including the master) that are idle.
int nIdle;
- // The total number of workers (including the master).
+ //! The total number of workers (including the master).
int nTotal;
- // The temporary evaluation result.
+ //! The temporary evaluation result.
bool fAllOk;
- // Number of verifications that haven't completed yet.
- // This includes elements that are not anymore in queue, but still in
- // worker's own batches.
+ /**
+ * Number of verifications that haven't completed yet.
+ * This includes elements that are not anymore in queue, but still in
+ * worker's own batches.
+ */
unsigned int nTodo;
- // Whether we're shutting down.
+ //! Whether we're shutting down.
bool fQuit;
- // The maximum number of elements to be processed in one batch
+ //! The maximum number of elements to be processed in one batch
unsigned int nBatchSize;
- // Internal function that does bulk of the verification work.
+ /** Internal function that does bulk of the verification work. */
bool Loop(bool fMaster = false)
{
boost::condition_variable& cond = fMaster ? condMaster : condWorker;
@@ -124,22 +127,22 @@ private:
}
public:
- // Create a new check queue
+ //! Create a new check queue
CCheckQueue(unsigned int nBatchSizeIn) : nIdle(0), nTotal(0), fAllOk(true), nTodo(0), fQuit(false), nBatchSize(nBatchSizeIn) {}
- // Worker thread
+ //! Worker thread
void Thread()
{
Loop();
}
- // Wait until execution finishes, and return whether all evaluations where succesful.
+ //! Wait until execution finishes, and return whether all evaluations where successful.
bool Wait()
{
return Loop(true);
}
- // Add a batch of checks to the queue
+ //! Add a batch of checks to the queue
void Add(std::vector<T>& vChecks)
{
boost::unique_lock<boost::mutex> lock(mutex);
@@ -161,8 +164,9 @@ public:
friend class CCheckQueueControl<T>;
};
-/** RAII-style controller object for a CCheckQueue that guarantees the passed
- * queue is finished before continuing.
+/**
+ * RAII-style controller object for a CCheckQueue that guarantees the passed
+ * queue is finished before continuing.
*/
template <typename T>
class CCheckQueueControl