This kind of queue is called a blocking queue.
这种队列称为阻塞的队列。
Designing a concurrent blocking queue with timeouts.
设计有超时限制的并发阻塞队列。
Here are a couple of the finer aspects of the concurrent blocking queue design.
并发阻塞队列设计有两个要注意的方面。
Listing 7 shows the modified version of the pop operation for the blocking queue.
清单7给出阻塞队列的pop操作定义。
In a bounded blocking queue, the writer thread also needs to wait if the queue is full.
对于有大小限制的阻塞队列,如果队列满了,写线程也需要等待。
In a blocking queue, only the reader thread needs to wait when there is no data in the queue.
对于阻塞队列,只有读线程需要在队列中没有数据时等待。
This queue type is similar to a concurrent blocking queue except that the size of the queue is bounded.
这种队列与并发阻塞队列相似,但是对队列的大小有限制。
For those unfamiliar with the concept of a blocking queue, it is essentially a FIFO data structure, with a twist.
假如不熟悉阻塞队列概念,它实质上就是一种带有一点扭曲的FIFO数据结构。
Listing 6 shows a method that waits on a blocking queue until an item is available, regardless of whether it is interrupted.
清单6展示了一个方法,该方法等待一个阻塞队列,直到队列中出现一个可用项目,而不管它是否被中断。
The first thing of note in Listing 13 and Listing 14 is that there are two condition variables instead of the one that the blocking queue had.
对于清单13和清单14,要注意的第一点是,这个阻塞队列有两个条件变量而不是一个。
When that consumer is available, the element is passed directly between consumer and producer, never literally getting added to the blocking queue.
当这个消费者出现时,这个元素就直接在消费者和生产者之间传递,永远不会加入到阻塞队列中。
Although the functionality of the blocking queue is not compromised with this choice, use of pthread_cond_signal could potentially lead to unacceptable wait times for some reader threads.
尽管使用pthread_cond_signal不会损害阻塞队列的功能,但是这可能会导致某些读线程的等待时间过长。
Removes the next reference object in this queue, blocking until one becomes available.
从队列中删除下一个引用对象,阻塞直到有一个可用。
Removes the next reference object in this queue, blocking until either one becomes available or the given timeout period expires.
从队列中删除下一个引用对象,阻塞直到有一个可用或给定超时期满。
Designing a concurrent blocking bounded queue.
设计有大小限制的并发阻塞队列。
Designing a concurrent blocking bounded queue.
设计有大小限制的并发阻塞队列。
应用推荐