java.lang.Object | |
↳ | com.facebook.common.executors.StatefulRunnable<T> |
Known Direct Subclasses |
Abstraction for computation.
Computation expressed as StatefulRunnable can be cancelled, but only if it has not started yet.
For better decoupling of the code computing the result and the code that handles it, 4 separate methods are provided: getResult, onSuccess, onFailure and onCancellation.
This runnable can be run only once. Subsequent calls to run method won't have any effect.
Constants | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
int | STATE_CANCELLED | ||||||||||
int | STATE_CREATED | ||||||||||
int | STATE_FAILED | ||||||||||
int | STATE_FINISHED | ||||||||||
int | STATE_STARTED |
Fields | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
protected final AtomicInteger | mState |
Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
StatefulRunnable() |
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
void | cancel() | ||||||||||
final void | run() |
Protected Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
void |
disposeResult(T result)
Called after onSuccess callback completes in order to dispose the result.
| ||||||||||
abstract T | getResult() | ||||||||||
void |
onCancellation()
Called when the runnable is cancelled.
| ||||||||||
void |
onFailure(Exception e)
Called if exception occurred during computation.
| ||||||||||
void |
onSuccess(T result)
Called after computing result successfully.
|
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class
java.lang.Object
| |||||||||||
From interface
java.lang.Runnable
|
Called after onSuccess callback completes in order to dispose the result.
Exception |
---|
Called when the runnable is cancelled.
Called if exception occurred during computation.
Called after computing result successfully.