X-Git-Url: https://git.novaco.in/?p=novacoin.git;a=blobdiff_plain;f=src%2Fcheckqueue.h;h=43895739409d83f73f03d6de60ae35a913609ae1;hp=10fad2ed31a11fbf703ed7e379e93571a18eb311;hb=481b23fcc7039cfc25ecf2069c3d9c73e832360f;hpb=9d314f181af7c43ad8cd7223c08486e316bef5e2 diff --git a/src/checkqueue.h b/src/checkqueue.h index 10fad2e..4389573 100644 --- a/src/checkqueue.h +++ b/src/checkqueue.h @@ -7,10 +7,10 @@ #include #include +#include +#include +#include -#include -#include -#include extern bool fShutdown; @@ -28,16 +28,16 @@ template class CCheckQueueControl; template class CCheckQueue { private: // Mutex to protect the inner state - boost::mutex mutex; + std::mutex mutex; // Worker threads block on this when out of work - boost::condition_variable condWorker; + std::condition_variable condWorker; // Master thread blocks on this when out of work - boost::condition_variable condMaster; + std::condition_variable condMaster; // Quit method blocks on this until all workers are gone - boost::condition_variable condQuit; + std::condition_variable condQuit; // The queue of elements to be processed. // As the order of booleans doesn't matter, it is used as a LIFO (stack) @@ -65,14 +65,14 @@ private: // Internal function that does bulk of the verification work. bool Loop(bool fMaster = false) { - boost::condition_variable &cond = fMaster ? condMaster : condWorker; + std::condition_variable &cond = fMaster ? condMaster : condWorker; std::vector vChecks; vChecks.reserve(nBatchSize); unsigned int nNow = 0; bool fOk = true; do { { - boost::unique_lock lock(mutex); + std::unique_lock lock(mutex); // first do the clean-up of the previous loop run (allowing us to do it in the same critsect) if (nNow) { fAllOk &= fOk; @@ -143,7 +143,7 @@ public: // Add a batch of checks to the queue void Add(std::vector &vChecks) { - boost::unique_lock lock(mutex); + std::unique_lock lock(mutex); for (T &check : vChecks) { queue.push_back(T()); check.swap(queue.back()); @@ -157,7 +157,7 @@ public: // Shut the queue down void Quit() { - boost::unique_lock lock(mutex); + std::unique_lock lock(mutex); fQuit = true; // No need to wake the master, as he will quit automatically when all jobs are // done. @@ -173,7 +173,7 @@ public: bool IsIdle() { - boost::unique_lock lock(mutex); + std::unique_lock lock(mutex); return (nTotal == nIdle && nTodo == 0 && fAllOk == true); } }; @@ -189,14 +189,14 @@ private: public: CCheckQueueControl(CCheckQueue *pqueueIn) : pqueue(pqueueIn), fDone(false) { // passed queue is supposed to be unused, or NULL - if (pqueue != NULL) { + if (pqueue != nullptr) { bool isIdle = pqueue->IsIdle(); assert(isIdle); } } bool Wait() { - if (pqueue == NULL) + if (pqueue == nullptr) return true; bool fRet = pqueue->Wait(); fDone = true; @@ -204,7 +204,7 @@ public: } void Add(std::vector &vChecks) { - if (pqueue != NULL) + if (pqueue != nullptr) pqueue->Add(vChecks); }