Package com.naver.ads.deferred
Class DeferredCompletionSource
-
- All Implemented Interfaces:
public final class DeferredCompletionSource<TResult extends Object>Allows safe orchestration of a Deferred's completion, preventing the consumer from prematurely completing the deferred.
Essentially, it represents the producer side of a Deferred, providing access to the consumer side through the getDeferred method while isolating the Deferred's completion mechanisms from the consumer.
-
-
Constructor Summary
Constructors Constructor Description DeferredCompletionSource(CancellationToken cancellationToken)
-
Method Summary
Modifier and Type Method Description final UnitsetResult(TResult result)Sets the result of the Deferred, throwing if the Deferred has already been completed. final BooleantrySetResult(TResult result)Sets the result on the Deferred if the Deferred hasn't already been completed. final UnitsetException(Exception e)Sets the error of the Deferred, throwing if the Deferred has already been completed. final UnittrySetException(Exception e)Sets the error on the Deferred if the Deferred hasn't already been completed. final Deferred<TResult>getDeferred()Returns the Deferred associated with this DeferredCompletionSource -
-
Constructor Detail
-
DeferredCompletionSource
DeferredCompletionSource(CancellationToken cancellationToken)
-
-
Method Detail
-
trySetResult
final Boolean trySetResult(TResult result)
-
setException
final Unit setException(Exception e)
-
trySetException
final Unit trySetException(Exception e)
-
getDeferred
final Deferred<TResult> getDeferred()
Returns the Deferred associated with this DeferredCompletionSource
-
-
-
-