class PromiseImpl extends Promise<R> implements ActionHandle {

    @NonNull
    @Override
    public ActionHandle then(@Nullable ResultListener<R> listener) {
        final R result = mResult;
        final ResourceCleaner<R> cleaner = mCleaner;
        mResult = null;

        if (listener != null) {
            listener.onResult(result);
        } else if (cleaner != null && result != null) {
            cleaner.clean(result);
        }

        mResult = null;
        mCleaner = null;
        return this;
    }

      PromiseImpl(@Nullable R result, @Nullable ResourceCleaner<R> cleaner);

}