Use a counter, not a bool.
{
dout(10) << "drain" << dendl;
_lock.Lock();
- _draining = true;
+ _draining++;
while (processing || (wq != NULL && !wq->_empty()))
_wait_cond.Wait(_lock);
- _draining = false;
+ _draining--;
_lock.Unlock();
}
string name;
Mutex _lock;
Cond _cond;
- bool _stop, _pause, _draining;
+ bool _stop, _pause;
+ int _draining;
Cond _wait_cond;
struct _WorkQueue {
name(nm),
_lock((new string(name + "::lock"))->c_str()), // deliberately leak this
_stop(false),
- _pause(false), _draining(false),
+ _pause(false),
+ _draining(0),
last_work_queue(0),
processing(0) {
set_num_threads(n);