当队列是空的时候,读线程现在并不抛出异常,而是在条件变量上阻塞自身。
Instead of throwing an exception when the queue is empty, the reader thread now blocks itself on the condition variable.
第一个读线程锁住互斥锁,发现队列是空的,然后在 _cond 上阻塞自身,这会隐式地释放互斥锁。
The first reader thread locked the mutex, realized that the queue is empty, and blocked itself on _cond, which implicitly released the mutex.
当线程的任务队列为空,它将尝试从另一个线程的deque的尾部窃取另一个任务。
In the event the thread's task queue is empty, it then tries to steal another task off the tail of another thread's deque.
应用推荐