Class FairBlockingQueue.ItemFuture<T>
java.lang.Object
org.apache.tomcat.jdbc.pool.FairBlockingQueue.ItemFuture<T>
- Type Parameters:
T- the type of the item
- All Implemented Interfaces:
Future<T>
- Enclosing class:
FairBlockingQueue<E>
A future used to check if a connection has been made available. Cancelling the future deregisters its waiter from
the queue, as long as the item has not already been handed over to the future.
A
A
get(long, TimeUnit) call that times out deregisters the waiter in the same way, and additionally fails
the future terminally: no offer can reach the deregistered latch anymore, so the future reports isDone()
true without ever being cancelled, keeps failing every later get(long, TimeUnit) with a
TimeoutException and every later get() with an ExecutionException caused by one, and can
no longer be cancelled.-
Nested Class Summary
Nested classes/interfaces inherited from interface Future
Future.State -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected booleanWhether aget(long, TimeUnit)call on this future timed out.protected booleanWhether this future has been cancelled.protected TThe item directly available in the future.protected FairBlockingQueue<E>.ExchangeCountDownLatch<T> The latch used to wait for an item. -
Constructor Summary
ConstructorsConstructorDescriptionItemFuture(FairBlockingQueue<E>.ExchangeCountDownLatch<T> latch) Creates an ItemFuture that waits on the given latch.ItemFuture(T item) Creates an ItemFuture with the given item already available. -
Method Summary
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface Future
exceptionNow, resultNow, state
-
Field Details
-
item
The item directly available in the future. -
latch
The latch used to wait for an item. -
canceled
protected volatile boolean canceledWhether this future has been cancelled. -
abandoned
protected volatile boolean abandonedWhether aget(long, TimeUnit)call on this future timed out. Its waiter was then deregistered from the queue, so no item can ever be handed over to this future anymore; the future is terminally failed and its get() methods fail fast instead of parking on a latch that nothing can count down again.
-
-
Constructor Details
-
ItemFuture
Creates an ItemFuture with the given item already available.- Parameters:
item- the item
-
ItemFuture
Creates an ItemFuture that waits on the given latch.- Parameters:
latch- the latch to wait on
-
-
Method Details
-
cancel
-
get
- Specified by:
getin interfaceFuture<T>- Throws:
InterruptedExceptionExecutionException
-
get
public T get(long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException - Specified by:
getin interfaceFuture<T>- Throws:
InterruptedExceptionExecutionExceptionTimeoutException
-
isCancelled
public boolean isCancelled()- Specified by:
isCancelledin interfaceFuture<T>
-
isDone
-