01: /*
02: * All content copyright (c) 2003-2006 Terracotta, Inc., except as may otherwise be noted in a separate copyright notice. All rights reserved.
03: */
04: package com.tc.util.concurrent;
05:
06: /**
07: * Adds methods to the regular queue interface for blocking queue implementations. Similar to <code>Queue</code>,
08: * this interface is modelled after the java.util.concurrent.BlockingQueue interface
09: *
10: * @author orion
11: */
12: public interface BlockingQueue extends Queue {
13: /**
14: * Place item in queue only if it can be accepted within the given timeout
15: *
16: * @param o the object to offer to the queue (should be non-null)
17: * @param timeout the number of milliseconds to wait. If less than or equal to zero, do not perform any timed waits
18: * @return true if accepted, else false
19: * @throws InterruptedException if the current thread has been interrupted at a point at which interruption is
20: * detected, in which case the element is guaranteed not to be inserted (i.e., is equivalent to a false
21: * return).
22: */
23: boolean offer(Object o, long timeout) throws InterruptedException;
24:
25: /**
26: * Return and remove an item from channel only if one is available within the given timeout period
27: *
28: * @param timeout the number of milliseconds to wait. If less than or equal to zero, do not perform any timed waits
29: * @return an item, or null if the channel is empty.
30: * @throws InterruptedException if the current thread has been interrupted at a point at which interruption is
31: * detected, in which case state of the channel is unchanged (i.e., equivalent to a null return).
32: */
33: Object poll(long timeout) throws InterruptedException;
34:
35: /**
36: * Return and remove an item from this queue, possibly waiting indefinitely until such an item exists.
37: *
38: * @return an item from the queue. Order of the return item (vs. insertion order) is governed by the implementation
39: * @throws InterruptedException if the current thread has been interrupted at a point at which interruption is
40: * detected, in which case state of the queue is unchanged.
41: */
42: Object take() throws InterruptedException;
43: }
|