blocking_job takeJob() throw(QueueBreak) { MutexGuard lock(&mutex_); while(queue_.size()==0 && running_) { cond_.wait(mutex_);//release mutex and block here } //printf("thread wake: %s %d, and should do some job assignment here:%d\n", //Thread::ThreadName().c_str(), Thread::GetTid(), count); if(!running_) { throw QueueBreak("QueueBreak"); } blocking_job job = 0; if(queue_.size()) { job = queue_.front(); queue_.pop_front(); } if(queue_.size()) cond_.notify(); return job; }