Package jadex.future
Interface IFuture<E>
- All Superinterfaces:
Supplier<E>
- All Known Subinterfaces:
IIntermediateFuture<E>
,IPullIntermediateFuture<E>
,IPullSubscriptionIntermediateFuture<E>
,ISubscriptionIntermediateFuture<E>
,ITerminableFuture<E>
,ITerminableIntermediateFuture<E>
,ITuple2Future<E,
F>
- All Known Implementing Classes:
Future
,IntermediateFuture
,PullIntermediateDelegationFuture
,PullIntermediateFuture
,PullSubscriptionIntermediateDelegationFuture
,PullSubscriptionIntermediateFuture
,SubscriptionIntermediateDelegationFuture
,SubscriptionIntermediateFuture
,TerminableDelegationFuture
,TerminableFuture
,TerminableIntermediateDelegationFuture
,TerminableIntermediateFuture
,Tuple2Future
Interface for futures. Similar to Java Future interface but adds a listener
notification mechanism.
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionvoid
addResultListener
(IResultListener<E> listener) Add a result listener.Called on exception.Called on exception.Called on exception.void
Deprecated.Use delegateTo.void
delegateTo
(Future<E> target) Forward the result and exception to another future.get()
Get the result - blocking call.get
(boolean realtime) Get the result - blocking call.get
(long timeout) Get the result - blocking call.get
(long timeout, boolean realtime) Get the result - blocking call.get
(ThreadSuspendable sus) Deprecated.- From 3.0.Get the exception, if any.boolean
isDone()
Test if done, i.e.Print an exception.Applies a function after the result is available, using the result of this Future as input.<T> IFuture
<T> Applies a function after the result is available, using the result of this Future as input.<T> IFuture
<T> Applies a function after the result is available, using the result of this Future as input.<T> IFuture
<T> thenCompose
(Function<? super E, IFuture<T>> function) The result of this future is delegated to the given (future-returning) function.<T> IFuture
<T> thenCompose
(Function<? super E, IFuture<T>> function, Class<?> futuretype) The result of this future is delegated to the given (future-returning) function.
-
Field Details
-
DONE
A future representing a completed action. Can be used as direct return value of methods that do not perform asynchronous operations and do not return a result value. -
TRUE
A future representing a true result. -
FALSE
A future representing a false result.
-
-
Method Details
-
isDone
boolean isDone()Test if done, i.e. result is available.- Returns:
- True, if done.
-
getException
Exception getException()Get the exception, if any.- Returns:
- The exception, if any, or null if the future is not yet done or succeeded without exception.
-
get
E get()Get the result - blocking call. -
get
Get the result - blocking call.- Parameters:
realtime
- Flag, if wait should be realtime (in constrast to simulation time).- Returns:
- The future result.
-
get
Get the result - blocking call.- Parameters:
timeout
- The timeout in millis.- Returns:
- The future result.
-
get
Get the result - blocking call.- Parameters:
timeout
- The timeout in millis.realtime
- Flag, if wait should be realtime (in constrast to simulation time).- Returns:
- The future result.
-
get
Deprecated.- From 3.0. Use the version without suspendable. Will NOT use the suspendable given as parameter. Get the result - blocking call.- Returns:
- The future result.
-
addResultListener
Add a result listener.- Parameters:
listener
- The listener.
-
then
Applies a function after the result is available, using the result of this Future as input.- Parameters:
function
- Function that takes the result of this future as input and delivers t.- Returns:
- Future of the result after the function has been applied.
-
thenApply
Applies a function after the result is available, using the result of this Future as input.- Parameters:
function
- Function that takes the result of this future as input and delivers t.- Returns:
- Future of the result after the function has been applied.
-
thenApply
Applies a function after the result is available, using the result of this Future as input.- Parameters:
function
- Function that takes the result of this future as input and delivers t.futuretype
- The type of the return future.- Returns:
- Future of the result after the function has been applied.
-
thenCompose
The result of this future is delegated to the given (future-returning) function. The result of the function will be available in the returned future.- Parameters:
function
- Function that takes the result of this future as input and delivers future(t).- Returns:
- Future of the result of the second async call.
-
thenCompose
The result of this future is delegated to the given (future-returning) function. The result of the function will be available in the returned future.- Parameters:
function
- Function that takes the result of this future as input and delivers future(t).futuretype
- The type of the return future. If null, a default future is created.- Returns:
- Future of the result of the second async call.
-
catchEx
Called on exception.- Parameters:
delegate
- The future the exception will be delegated to.
-
catchEx
Called on exception.- Parameters:
consumer
- The function called with the exception.
-
catchEx
Called on exception.- Parameters:
consumer
- The function called with the exception.
-
printOnEx
Print an exception. -
delegate
Deprecated.Use delegateTo.Delegate the result and exception to another future. Short form for adding a delegation listener.- Parameters:
delegate
- The other future.
-
delegateTo
Forward the result and exception to another future. Short form for adding a delegation listener.- Parameters:
target
- The target future.
-