Interface Queue<T>
-
Nested Class Summary
Nested Classes -
Method Summary
Methods inherited from interface io.aleph0.yap.core.Measureable
checkMetrics, flushMetrics
-
Method Details
-
tryReceive
T tryReceive()Attempts to receive a message from the queue. This method will return immediately, even if there are no messages available in the queue. Returnsnullif the queue is empty, whethere it is closed or not, so users must not conclude that the queue is closed and drained from this method returningnull.- Returns:
- the message received from the queue, or
nullif the queue is empty
-
receive
Receives a message from the queue, waiting if necessary. This method will block until a message is received from the queue or the timeout expires. If the queue is closed and drained, this method will returnnull. Users may conclude that the queue is closed and drained from this method returningnull.- Parameters:
timeout- the maximum time to wait for a message to be received- Returns:
- the message received from the queue, or
nullif the queue is closed and drained - Throws:
InterruptedException- if the thread is interrupted while waitingTimeoutException- if the wait times out before a message is received
-
receive
Receives a message from the queue, waiting if necessary. This method will block until a message is received from the queue. If the queue is closed and drained, this method will returnnull. Users may conclude that the queue is closed and drained from this method returningnull.- Returns:
- the message received from the queue, or
nullif the queue is closed and drained - Throws:
InterruptedException- if the thread is interrupted while waiting
-
isDrained
boolean isDrained()
-