X-Git-Url: https://git.novaco.in/?a=blobdiff_plain;f=src%2Fcheckqueue.h;h=c4c35e5f80f7cab56c324a32f447854a7ceba395;hb=2404891de8ac5b357d0abde90f2e286a3153fdef;hp=0ae4020f3e65b7597d4d0fb1a0e0ebd59c845229;hpb=dc51de08660798825d497e79dfad8925c6d442c7;p=novacoin.git diff --git a/src/checkqueue.h b/src/checkqueue.h index 0ae4020..c4c35e5 100644 --- a/src/checkqueue.h +++ b/src/checkqueue.h @@ -13,6 +13,8 @@ #include #include +extern bool fShutdown; + template class CCheckQueueControl; /** Queue for verifications that have to be performed. @@ -121,7 +123,8 @@ private: if (fOk) fOk = check(); vChecks.clear(); - } while(true); + } while(true && !fShutdown); // HACK: force queue to shut down + return false; } public: @@ -165,7 +168,15 @@ public: condQuit.wait(lock); } - friend class CCheckQueueControl; + ~CCheckQueue() { + Quit(); + } + + bool IsIdle() + { + boost::unique_lock lock(mutex); + return (nTotal == nIdle && nTodo == 0 && fAllOk == true); + } }; /** RAII-style controller object for a CCheckQueue that guarantees the passed @@ -180,9 +191,8 @@ public: CCheckQueueControl(CCheckQueue *pqueueIn) : pqueue(pqueueIn), fDone(false) { // passed queue is supposed to be unused, or NULL if (pqueue != NULL) { - assert(pqueue->nTotal == pqueue->nIdle); - assert(pqueue->nTodo == 0); - assert(pqueue->fAllOk == true); + bool isIdle = pqueue->IsIdle(); + assert(isIdle); } }