Package com.naver.ads.deferred
Class CallableDeferredNode
-
- All Implemented Interfaces:
-
com.naver.ads.deferred.DeferredNode,java.util.concurrent.Callable
public abstract class CallableDeferredNode<T extends Object> implements DeferredNode, Callable<T>
An implementation of DeferredNode that implements Callable.
-
-
Constructor Summary
Constructors Constructor Description CallableDeferredNode(DeferredQueue deferredQueue, DeferredNodeItem deferredNodeItem)Constructs a new CallableDeferredNode instance.
-
Method Summary
Modifier and Type Method Description RunnablegetRunnable()Returns the underlying task. UnithandleError(Exception exception)Handles the error in this DeferredNode. BooleanisCompleted()Return whether this DeferredNode is completed. Tcall()Computes a result. abstract Tapply()Override this method to perform a computation on a background thread. final Tget()Waits If necessary for the computation to complete, and then retrieves its result. final Tget(Long timeout, TimeUnit unit)Waits if necessary for at most the given time for the computation to complete, and then retrieves its result. abstract UnitonResponse(T response)Runs on the UI thread after apply. abstract UnitonFailure(Exception exception)Runs on the UI thread after apply. -
-
Constructor Detail
-
CallableDeferredNode
CallableDeferredNode(DeferredQueue deferredQueue, DeferredNodeItem deferredNodeItem)
Constructs a new CallableDeferredNode instance.
-
-
Method Detail
-
getRunnable
Runnable getRunnable()
Returns the underlying task.
-
handleError
Unit handleError(Exception exception)
Handles the error in this DeferredNode.
-
isCompleted
Boolean isCompleted()
Return whether this DeferredNode is completed.
-
apply
abstract T apply()
Override this method to perform a computation on a background thread.
- Returns:
the computed result.
-
get
final T get()
Waits If necessary for the computation to complete, and then retrieves its result.
- Returns:
the computed result.
-
get
final T get(Long timeout, TimeUnit unit)
Waits if necessary for at most the given time for the computation to complete, and then retrieves its result.
- Parameters:
timeout- time to wait before cancelling the operation.unit- the time unit for the timeout.- Returns:
the computed result.
-
onResponse
@UiThread() abstract Unit onResponse(T response)
Runs on the UI thread after apply. The specified result is the value returned by apply.
This method won't be invoked if the deferred was canceled or an error occurred.
- Parameters:
response- the response of the operation computed by apply.
-
-
-
-