A queue with extended capability of blocking on pulling operation until data is available.
With the ordinary queue the dequeue operation returns immediately with the element at the head, or null if the queue is empty. A blocking queue, however, supports dequeuing with extended waiting time, during which it will put the current thread into a waiting thread. When a new element is added, it will notify the waiting threads, so that the dequeue operation can proceed.
Parent Class
Type | Name | Signature |
---|---|---|
constructor | BlockingQueue | public BlockingQueue() |
method | dequeue | public var dequeue() |
method | enqueue | public void enqueue(var) |
method | pull | public var pull(int, bool) |
public BlockingQueue()
Create a new blocking queue.
public var dequeue()
Remove an element from the head of queue.
This method preserves the behavior of the parent class. It won't wait on an empty queue, and it will return null if the queue is empty.
Returns
See Also
public void enqueue(var ele)
Add a new element to the tail of queue. This will notify all the threads waiting at the call to pull.
Parameters
public var pull(int timeoutInMillisec, bool throwIfTimeout)
Remove an element from the head of queue. If the queue is empty, wait for specified duration. If new data becomes available within the duration this method will return successfully. Otherwise it either returns null, or throws, upon expiration.
This method will send the current thread into waiting state. Use caution to avoid deadlock.
Parameters
Returns
Throws