fm.liveswitch.Future< T > Class Template Referenceabstract

A future. More...

Public Member Functions

abstract fm.liveswitch.Future< T > fail (fm.liveswitch.IAction1< java.lang.Exception > rejectAction)
 Appends a handler to be executed when the promise is rejected. More...
 
abstract fm.liveswitch.Future< T > fail (fm.liveswitch.IFunction1< java.lang.Exception, fm.liveswitch.Future< T >> rejectFunction)
 Appends a handler to be executed when the promise is rejected. More...
 
abstract fm.liveswitch.Future< T > then (fm.liveswitch.IAction1< T > resolveAction)
 Appends a handler to be executed when the promise is resolved. More...
 
abstract fm.liveswitch.Future< T > then (fm.liveswitch.IAction1< T > resolveAction, fm.liveswitch.IAction1< java.lang.Exception > rejectAction)
 Appends handlers to be executed when the promise is resolved or rejected. More...
 
abstract< R extends Object > fm.liveswitch.Future< R > then (fm.liveswitch.IFunction1< T, fm.liveswitch.Future< R >> resolveFunction)
 Appends a handler to be executed when the promise is resolved. More...
 
abstract< R extends Object > fm.liveswitch.Future< R > then (fm.liveswitch.IFunction1< T, fm.liveswitch.Future< R >> resolveFunction, fm.liveswitch.IAction1< java.lang.Exception > rejectAction)
 Appends handlers to be executed when the promise is resolved or rejected. More...
 
void waitForPromise ()
 Blocks the current thread from proceeding until the future state has been resolved or rejected. More...
 
void waitForPromise (int millisecondsTimeout)
 Blocks the current thread from proceeding until the future state has been resolved or rejected or if the timeout period elapses. More...
 
waitForResult ()
 Blocks the current thread from proceeding until the future has a result. More...
 
waitForResult (int millisecondsTimeout)
 Blocks the current thread from proceeding until the future has a result. More...
 
- Public Member Functions inherited from fm.liveswitch.FutureBase< T >
java.lang.Exception getException ()
 Gets the exception if rejected. More...
 
getResult ()
 Gets the result if resolved. More...
 
fm.liveswitch.FutureState getState ()
 Gets the current state. More...
 

Protected Member Functions

 Future ()
 
- Protected Member Functions inherited from fm.liveswitch.FutureBase< T >
 FutureBase ()
 
void setException (java.lang.Exception value)
 Sets the exception if rejected. More...
 
void setResult (T value)
 Sets the result if resolved. More...
 
void setState (fm.liveswitch.FutureState value)
 Sets the current state. More...
 

Detailed Description

A future.

Constructor & Destructor Documentation

◆ Future()

fm.liveswitch.Future< T >.Future ( )
protected

Member Function Documentation

◆ fail() [1/2]

abstract fm.liveswitch.Future<T> fm.liveswitch.Future< T >.fail ( fm.liveswitch.IAction1< java.lang.Exception >  rejectAction)
abstract

Appends a handler to be executed when the promise is rejected.

Parameters
rejectActionThe reject action.

Reimplemented in fm.liveswitch.Promise< T >.

◆ fail() [2/2]

abstract fm.liveswitch.Future<T> fm.liveswitch.Future< T >.fail ( fm.liveswitch.IFunction1< java.lang.Exception, fm.liveswitch.Future< T >>  rejectFunction)
abstract

Appends a handler to be executed when the promise is rejected.

Parameters
rejectFunctionThe reject function.

Reimplemented in fm.liveswitch.Promise< T >.

◆ then() [1/4]

abstract fm.liveswitch.Future<T> fm.liveswitch.Future< T >.then ( fm.liveswitch.IAction1< T >  resolveAction)
abstract

Appends a handler to be executed when the promise is resolved.

Parameters
resolveActionThe resolve action.

Reimplemented in fm.liveswitch.Promise< T >.

◆ then() [2/4]

abstract fm.liveswitch.Future<T> fm.liveswitch.Future< T >.then ( fm.liveswitch.IAction1< T >  resolveAction,
fm.liveswitch.IAction1< java.lang.Exception >  rejectAction 
)
abstract

Appends handlers to be executed when the promise is resolved or rejected.

Parameters
resolveActionThe resolve action.
rejectActionThe reject action.

Reimplemented in fm.liveswitch.Promise< T >.

◆ then() [3/4]

abstract <R extends Object> fm.liveswitch.Future<R> fm.liveswitch.Future< T >.then ( fm.liveswitch.IFunction1< T, fm.liveswitch.Future< R >>  resolveFunction)
abstract

Appends a handler to be executed when the promise is resolved.

Parameters
resolveFunctionThe resolve function.

◆ then() [4/4]

abstract <R extends Object> fm.liveswitch.Future<R> fm.liveswitch.Future< T >.then ( fm.liveswitch.IFunction1< T, fm.liveswitch.Future< R >>  resolveFunction,
fm.liveswitch.IAction1< java.lang.Exception >  rejectAction 
)
abstract

Appends handlers to be executed when the promise is resolved or rejected.

Parameters
resolveFunctionThe resolve function.
rejectActionThe reject action.

◆ waitForPromise() [1/2]

void fm.liveswitch.Future< T >.waitForPromise ( )

Blocks the current thread from proceeding until the future state has been resolved or rejected.

◆ waitForPromise() [2/2]

void fm.liveswitch.Future< T >.waitForPromise ( int  millisecondsTimeout)

Blocks the current thread from proceeding until the future state has been resolved or rejected or if the timeout period elapses.

Parameters
millisecondsTimeoutThe number of milliseconds to wait before timing out.

◆ waitForResult() [1/2]

T fm.liveswitch.Future< T >.waitForResult ( )

Blocks the current thread from proceeding until the future has a result.

Throws an exception if the promise is rejected.

◆ waitForResult() [2/2]

T fm.liveswitch.Future< T >.waitForResult ( int  millisecondsTimeout)

Blocks the current thread from proceeding until the future has a result.

Throws an exception if the promise is rejected or if the timeout period elapses.

Parameters
millisecondsTimeoutThe number of milliseconds to wait before timing out.