java.util.concurrent.BlockingQueue are implemented.
| Modifier and Type | Class and Description |
|---|---|
| protected class | |
| protected class | |
| protected class |
| Modifier and Type | Field and Description |
|---|---|
| pack-priv static final boolean | isLinux
This little sucker is used to reorder the way to do
|
| pack-priv final LinkedList | items
All the objects in the pool are stored in a simple linked list |
| pack-priv final ReentrantLock | lock
Phase one entry lock in order to give out per-thread-locks for the waiting phase we have a phase one lock during the contention period. |
| pack-priv final LinkedList | waiters
All threads waiting for an object are stored in a linked list |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| public boolean | add(E
the element to add e)Implements java. Inserts the specified element into this queue if it is possible to do
so immediately without violating capacity restrictions, returning
|
| public boolean | addAll(Collection<? extends E>
collection containing elements to be added to this collection c)Implements java. Adds all of the elements in the specified collection to this collection (optional operation). |
| public void | clear()
Implements java. Removes all of the elements from this collection (optional operation). |
| public boolean | contains(Object
object to be checked for containment in this queue e)Implements java. Returns |
| public boolean | containsAll(Collection<?>
collection to be checked for containment in this collection c)Implements java. Returns |
| public int | drainTo(Collection<? super E>
the collection to transfer elements into c, int the maximum number of elements to transfer maxElements)Implements java. Removes at most the given number of available elements from this queue and adds them to the given collection. |
| public int | drainTo(Collection<? super E>
the collection to transfer elements into c)Implements java. Removes all available elements from this queue and adds them to the given collection. |
| public E | element()
Implements java. Retrieves, but does not remove, the head of this queue. |
| public boolean | isEmpty()
Implements java. Returns |
| public Iterator | iterator()
Implements java. Returns an iterator over the elements in this collection. |
| public boolean | offer(E
the element to add e)Implements java. Will always return true, queue is unbounded. |
| public boolean | offer(E
the element to add e, long how long to wait before giving up, in units of
timeout, TimeUnit unita unit)TimeUnit determining how to interpret the
timeout parameterImplements java. Will never timeout, as it invokes the |
| public E | peek()
Implements java. Retrieves, but does not remove, the head of this queue,
or returns |
| public E | poll(long
how long to wait before giving up, in units of
timeout, TimeUnit unita unit)TimeUnit determining how to interpret the
timeout parameterImplements java. Fair retrieval of an object in the queue. |
| public E | poll()
Implements java. Retrieves and removes the head of this queue,
or returns |
| public Future | Returns: - a future pending the result from the queue poll requestRequest an item from the queue asynchronously |
| public void | put(E
the element to add e)Implements java. Inserts the specified element into this queue, waiting if necessary for space to become available. |
| public int | remainingCapacity()
Implements java. Returns the number of additional elements that this queue can ideally
(in the absence of memory or resource constraints) accept without
blocking, or |
| public boolean | remove(Object
element to be removed from this queue, if present e)Implements java. Removes a single instance of the specified element from this queue, if it is present. |
| public E | |
| public boolean | removeAll(Collection<?>
collection containing elements to be removed from this collection c)Implements java. Removes all of this collection's elements that are also contained in the specified collection (optional operation). |
| public boolean | retainAll(Collection<?>
collection containing elements to be retained in this collection c)Implements java. Retains only the elements in this collection that are contained in the specified collection (optional operation). |
| public int | |
| public E | take()
Implements java. Retrieves and removes the head of this queue, waiting if necessary until an element becomes available. |
| public Object[] | toArray()
Implements java. Returns an array containing all of the elements in this collection. |
| public <T> T[] | toArray(T[]
the array into which the elements of this collection are to be
stored, if it is big enough; otherwise, a new array of the same
runtime type is allocated for this purpose. a)Implements java. Returns an array containing all of the elements in this collection; the runtime type of the returned array is that of the specified array. |
| isLinux | back to summary |
|---|---|
| pack-priv static final boolean isLinux This little sucker is used to reorder the way to do
| |
| items | back to summary |
|---|---|
| pack-priv final LinkedList<E> items All the objects in the pool are stored in a simple linked list | |
| lock | back to summary |
|---|---|
| pack-priv final ReentrantLock lock Phase one entry lock in order to give out per-thread-locks for the waiting phase we have a phase one lock during the contention period. | |
| waiters | back to summary |
|---|---|
| pack-priv final LinkedList<FairBlockingQueue<E>. All threads waiting for an object are stored in a linked list | |
| FairBlockingQueue | back to summary |
|---|---|
| public FairBlockingQueue() Creates a new fair blocking queue. | |
| add | back to summary |
|---|---|
| public boolean add(E e) Implements java. Doc from java. Inserts the specified element into this queue if it is possible to do
so immediately without violating capacity restrictions, returning
| |
| addAll | back to summary |
|---|---|
| public boolean addAll(Collection<? extends E> c) Implements java. Doc from java. Adds all of the elements in the specified collection to this collection (optional operation). The behavior of this operation is undefined if the specified collection is modified while the operation is in progress. (This implies that the behavior of this call is undefined if the specified collection is this collection, and this collection is nonempty.) If the specified collection has a defined encounter order, processing of its elements generally occurs in that order.
| |
| clear | back to summary |
|---|---|
| public void clear() Implements java. Doc from java. Removes all of the elements from this collection (optional operation). The collection will be empty after this method returns.
| |
| contains | back to summary |
|---|---|
| public boolean contains(Object e) Implements java. Doc from java. Returns | |
| containsAll | back to summary |
|---|---|
| public boolean containsAll(Collection<?> c) Implements java. Doc from java. Returns
| |
| drainTo | back to summary |
|---|---|
| public int drainTo(Collection<? super E> c, int maxElements) Implements java. Doc from java. Removes at most the given number of available elements from
this queue and adds them to the given collection. A failure
encountered while attempting to add elements to
collection
| |
| drainTo | back to summary |
|---|---|
| public int drainTo(Collection<? super E> c) Implements java. Doc from java. Removes all available elements from this queue and adds them
to the given collection. This operation may be more
efficient than repeatedly polling this queue. A failure
encountered while attempting to add elements to
collection
| |
| element | back to summary |
|---|---|
| public E element() Implements java. Doc from java. Retrieves, but does not remove, the head of this queue. This method
differs from
| |
| isEmpty | back to summary |
|---|---|
| public boolean isEmpty() Implements java. Doc from java. Returns
| |
| iterator | back to summary |
|---|---|
| public Iterator Implements java. Doc from java. Returns an iterator over the elements in this collection. There are no guarantees concerning the order in which the elements are returned (unless this collection is an instance of some class that provides a guarantee). | |
| offer | back to summary |
|---|---|
| public boolean offer(E e) Implements java. Doc from java. Will always return true, queue is unbounded.
Inserts the specified element into this queue if it is possible to do
so immediately without violating capacity restrictions, returning
| |
| offer | back to summary |
|---|---|
| public boolean offer(E e, long timeout, TimeUnit unit) throws InterruptedException Implements java. Doc from java. Will never timeout, as it invokes the
| |
| peek | back to summary |
|---|---|
| public E peek() Implements java. Doc from java. Retrieves, but does not remove, the head of this queue,
or returns
| |
| poll | back to summary |
|---|---|
| public E poll(long timeout, TimeUnit unit) throws InterruptedException Implements java. Doc from java. Fair retrieval of an object in the queue. Objects are returned in the order the threads requested them. Retrieves and removes the head of this queue, waiting up to the specified wait time if necessary for an element to become available.
| |
| poll | back to summary |
|---|---|
| public E poll() Implements java. Doc from java. Retrieves and removes the head of this queue,
or returns
| |
| pollAsync | back to summary |
|---|---|
| public Future Request an item from the queue asynchronously
| |
| put | back to summary |
|---|---|
| public void put(E e) throws InterruptedException Implements java. Doc from java. Inserts the specified element into this queue, waiting if necessary for space to become available.
| |
| remainingCapacity | back to summary |
|---|---|
| public int remainingCapacity() Implements java. Doc from java. Returns the number of additional elements that this queue can ideally
(in the absence of memory or resource constraints) accept without
blocking, or Note that you cannot always tell if an attempt to insert
an element will succeed by inspecting
| |
| remove | back to summary |
|---|---|
| public boolean remove(Object e) Implements java. Doc from java. Removes a single instance of the specified element from this queue,
if it is present. More formally, removes an element | |
| remove | back to summary |
|---|---|
| public E remove() Implements java. Doc from java. Retrieves and removes the head of this queue. This method differs
from
| |
| removeAll | back to summary |
|---|---|
| public boolean removeAll(Collection<?> c) Implements java. Doc from java. Removes all of this collection's elements that are also contained in the specified collection (optional operation). After this call returns, this collection will contain no elements in common with the specified collection.
| |
| retainAll | back to summary |
|---|---|
| public boolean retainAll(Collection<?> c) Implements java. Doc from java. Retains only the elements in this collection that are contained in the specified collection (optional operation). In other words, removes from this collection all of its elements that are not contained in the specified collection.
| |
| size | back to summary |
|---|---|
| public int size() Implements java. Doc from java. Returns the number of elements in this collection. If this collection
contains more than
| |
| take | back to summary |
|---|---|
| public E take() throws InterruptedException Implements java. Doc from java. Retrieves and removes the head of this queue, waiting if necessary until an element becomes available.
| |
| toArray | back to summary |
|---|---|
| public Object[] toArray() Implements java. Doc from java. Returns an array containing all of the elements in this collection.
If this collection makes any guarantees as to what order its elements
are returned by its iterator, this method must return the elements in
the same order. The returned array's runtime component type is The returned array will be "safe" in that no references to it are maintained by this collection. (In other words, this method must allocate a new array even if this collection is backed by an array). The caller is thus free to modify the returned array.
| |
| toArray | back to summary |
|---|---|
| public <T> T[] toArray(T[] a) Implements java. Doc from java. Returns an array containing all of the elements in this collection; the runtime type of the returned array is that of the specified array. If the collection fits in the specified array, it is returned therein. Otherwise, a new array is allocated with the runtime type of the specified array and the size of this collection. If this collection fits in the specified array with room to spare
(i.e., the array has more elements than this collection), the element
in the array immediately following the end of the collection is set to
If this collection makes any guarantees as to what order its elements are returned by its iterator, this method must return the elements in the same order.
| |
| Modifier and Type | Field and Description |
|---|---|
| protected volatile T |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| public T | |
| public void |
| item | back to summary |
|---|---|
| protected volatile T item | |
| ExchangeCountDownLatch | back to summary |
|---|---|
| public ExchangeCountDownLatch(int i) | |
| getItem | back to summary |
|---|---|
| public T getItem() | |
| setItem | back to summary |
|---|---|
| public void setItem(T item) | |
| Modifier and Type | Field and Description |
|---|---|
| pack-priv E | |
| pack-priv E[] | |
| pack-priv int |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| public boolean | |
| public E | |
| public void | remove()
Overrides default java. Removes from the underlying collection the last element returned by this iterator (optional operation). |
| element | back to summary |
|---|---|
| pack-priv E element | |
| elements | back to summary |
|---|---|
| pack-priv E[] elements | |
| index | back to summary |
|---|---|
| pack-priv int index | |
| FairIterator | back to summary |
|---|---|
public FairIterator()
| |
| hasNext | back to summary |
|---|---|
| public boolean hasNext() Implements java. Doc from java. Returns
| |
| next | back to summary |
|---|---|
| public E next() Implements java. Doc from java. Returns the next element in the iteration.
| |
| remove | back to summary |
|---|---|
| public void remove() Overrides default java. Doc from java. Removes from the underlying collection the last element returned
by this iterator (optional operation). This method can be called
only once per call to The behavior of an iterator is unspecified if the underlying collection is modified while the iteration is in progress in any way other than by calling this method, unless an overriding class has specified a concurrent modification policy.
The behavior of an iterator is unspecified if this method is called
after a call to the
| |
| Modifier and Type | Field and Description |
|---|---|
| protected volatile boolean | |
| protected volatile T | |
| protected volatile FairBlockingQueue |
| Access | Constructor and Description |
|---|---|
| public | |
| public |
| Modifier and Type | Method and Description |
|---|---|
| public boolean | cancel(boolean
true if the thread
executing this task should be interrupted (if the thread is
known to the implementation); otherwise, in-progress tasks are
allowed to completeImplements java. Attempts to cancel execution of this task. |
| public T | get()
Implements java. Waits if necessary for the computation to complete, and then retrieves its result. |
| public T | get(long
the maximum time to wait timeout, TimeUnit the time unit of the timeout argument unit)Implements java. Waits if necessary for at most the given time for the computation to complete, and then retrieves its result, if available. |
| public boolean | isCancelled()
Implements java. Returns |
| public boolean |
| canceled | back to summary |
|---|---|
| protected volatile boolean canceled | |
| item | back to summary |
|---|---|
| protected volatile T item | |
| latch | back to summary |
|---|---|
| protected volatile FairBlockingQueue<E>. | |
| ItemFuture | back to summary |
|---|---|
| public ItemFuture(T item) | |
| ItemFuture | back to summary |
|---|---|
| public ItemFuture(FairBlockingQueue<E>. | |
| cancel | back to summary |
|---|---|
| public boolean cancel(boolean mayInterruptIfRunning) Implements java. Doc from java. Attempts to cancel execution of this task. This method has no
effect if the task is already completed or cancelled, or could
not be cancelled for some other reason. Otherwise, if this
task has not started when The return value from this method does not necessarily
indicate whether the task is now cancelled; use
| |
| get | back to summary |
|---|---|
| public T get() throws InterruptedException, ExecutionException Implements java. Doc from java. Waits if necessary for the computation to complete, and then retrieves its result.
| |
| get | back to summary |
|---|---|
| public T get(long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException Implements java. Doc from java. Waits if necessary for at most the given time for the computation to complete, and then retrieves its result, if available.
| |
| isCancelled | back to summary |
|---|---|
| public boolean isCancelled() Implements java. Doc from java. Returns
| |
| isDone | back to summary |
|---|---|
| public boolean isDone() Implements java. Doc from java. Returns
| |