From 5cb82809ab9341b9cc5304fd31fe3590db813b09 Mon Sep 17 00:00:00 2001 From: dwight Date: Mon, 10 Jan 2011 17:07:39 -0500 Subject: [PATCH] mostly adding asserts and a little clarifying --- db/taskqueue.h | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/db/taskqueue.h b/db/taskqueue.h index 67a7abee5e7..0ffe6b4ee42 100644 --- a/db/taskqueue.h +++ b/db/taskqueue.h @@ -69,18 +69,19 @@ namespace mongo { */ void invoke() { mutex::scoped_lock lk2(_invokeMutex); - + int toDrain; { // flip queueing to the other queue (we are double buffered) - readlocktry lk("", 1); - if (lk.got()){ - int other = _which ^ 1; - if( _queues[other].empty() ) - _which = other; - } + readlocktry lk("", 5); + if( !lk.got() ) + return; + toDrain = _which; + _which = _which ^ 1; + wassert( _queues[_which].empty() ); // we are in dbMutex, so it should be/stay empty til we exit dbMutex } - _drain( _queues[_which^1] ); + _drain( _queues[toDrain] ); + assert( _queues[toDrain].empty() ); } private: