X-Git-Url: https://git.novaco.in/?p=novacoin.git;a=blobdiff_plain;f=src%2Fcheckqueue.h;h=c4c35e5f80f7cab56c324a32f447854a7ceba395;hp=36141dd74b60947fc61fcdf7bc1949953eaeaa18;hb=6aba6f08af53e3fa49ab4d1ef002e6771d0ce358;hpb=273ceadcc0475b03a2be03ffbeded0831d8232fc diff --git a/src/checkqueue.h b/src/checkqueue.h index 36141dd..c4c35e5 100644 --- a/src/checkqueue.h +++ b/src/checkqueue.h @@ -1,15 +1,19 @@ // Copyright (c) 2012 The Bitcoin developers // Distributed under the MIT/X11 software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. + #ifndef CHECKQUEUE_H #define CHECKQUEUE_H -#include -#include +#include +#include + +#include #include +#include +#include -#include -#include +extern bool fShutdown; template class CCheckQueueControl; @@ -119,7 +123,8 @@ private: if (fOk) fOk = check(); vChecks.clear(); - } while(true); + } while(true && !fShutdown); // HACK: force queue to shut down + return false; } public: @@ -163,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 @@ -178,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); } }