@Override
  public final void run() {
    if (!mState.compareAndSet(STATE_CREATED, STATE_STARTED)) {
      return;
    }
    T result;
    try {
      result = getResult();
    } catch (Exception e) {
      mState.set(STATE_FAILED);
      onFailure(e);
      return;
    }

    mState.set(STATE_FINISHED);
    try {
      onSuccess(result);
    } finally {
      disposeResult(result);
    }
  }
Abstraction for computation.

<p>Computation expressed as StatefulRunnable can be cancelled, but only if it has not started
yet.

<p>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.

<p>This runnable can be run only once. Subsequent calls to run method won't have any effect.
fbcore/src/main/java/com/facebook/common/executors/StatefulRunnable.java