Class SyncPromise<V>
- java.lang.Object
-
- org.apache.cassandra.utils.concurrent.AbstractFuture<V>
-
- org.apache.cassandra.utils.concurrent.SyncFuture<V>
-
- org.apache.cassandra.utils.concurrent.SyncPromise<V>
-
- All Implemented Interfaces:
com.google.common.util.concurrent.ListenableFuture<V>
,io.netty.util.concurrent.Future<V>
,io.netty.util.concurrent.Promise<V>
,java.util.concurrent.Future<V>
,Awaitable
,Future<V>
,Promise<V>
- Direct Known Subclasses:
SyncPromise.WithExecutor
public class SyncPromise<V> extends SyncFuture<V> implements Promise<V>
ExtendsSyncFuture
to implement thePromise
interface.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
SyncPromise.WithExecutor<V>
-
Nested classes/interfaces inherited from interface org.apache.cassandra.utils.concurrent.Awaitable
Awaitable.AbstractAwaitable, Awaitable.AsyncAwaitable, Awaitable.Defaults, Awaitable.SyncAwaitable
-
-
Field Summary
-
Fields inherited from class org.apache.cassandra.utils.concurrent.AbstractFuture
CANCELLED, UNCANCELLABLE, UNSET
-
-
Constructor Summary
Constructors Constructor Description SyncPromise()
SyncPromise(io.netty.util.concurrent.GenericFutureListener<? extends io.netty.util.concurrent.Future<? super V>> listener)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description SyncPromise<V>
addCallback(com.google.common.util.concurrent.FutureCallback<? super V> callback)
SupportFutures.addCallback(com.google.common.util.concurrent.ListenableFuture<V>, com.google.common.util.concurrent.FutureCallback<? super V>, java.util.concurrent.Executor)
natively SeeAbstractFuture.addListener(GenericFutureListener)
for ordering semantics.SyncPromise<V>
addCallback(com.google.common.util.concurrent.FutureCallback<? super V> callback, java.util.concurrent.Executor executor)
SupportFutures.addCallback(com.google.common.util.concurrent.ListenableFuture<V>, com.google.common.util.concurrent.FutureCallback<? super V>, java.util.concurrent.Executor)
natively SeeAbstractFuture.addListener(GenericFutureListener)
for ordering semantics.SyncPromise<V>
addCallback(java.util.function.Consumer<? super V> onSuccess, java.util.function.Consumer<? super java.lang.Throwable> onFailure)
Support more fluid version ofFutures.addCallback(com.google.common.util.concurrent.ListenableFuture<V>, com.google.common.util.concurrent.FutureCallback<? super V>, java.util.concurrent.Executor)
SeeAbstractFuture.addListener(GenericFutureListener)
for ordering semantics.SyncPromise<V>
addListener(io.netty.util.concurrent.GenericFutureListener<? extends io.netty.util.concurrent.Future<? super V>> listener)
Add a listener to be invoked once this future completes.SyncPromise<V>
addListeners(io.netty.util.concurrent.GenericFutureListener<? extends io.netty.util.concurrent.Future<? super V>>... listeners)
SyncPromise<V>
await()
Wait for this promise to completeSyncPromise<V>
awaitThrowUncheckedOnInterrupt()
Wait for this promise to complete, throwing any interrupt as an UncheckedInterruptedExceptionSyncPromise<V>
awaitUninterruptibly()
Wait uninterruptibly for this promise to completeboolean
isUncancellable()
SyncPromise<V>
removeListener(io.netty.util.concurrent.GenericFutureListener<? extends io.netty.util.concurrent.Future<? super V>> listener)
SyncPromise<V>
removeListeners(io.netty.util.concurrent.GenericFutureListener<? extends io.netty.util.concurrent.Future<? super V>>... listeners)
Promise<V>
setFailure(java.lang.Throwable throwable)
Complete the promise abnormally if not already completePromise<V>
setSuccess(V v)
Complete the promise successfully if not already completeboolean
setUncancellable()
Prevent a future caller from cancelling this promiseboolean
setUncancellableExclusive()
Prevent a future caller from cancelling this promisePromise<V>
sync()
waits for completion; in case of failure rethrows the original exception without a new wrapping exception so may cause problems for reporting stack tracesPromise<V>
syncUninterruptibly()
waits for completion; in case of failure rethrows the original exception without a new wrapping exception so may cause problems for reporting stack tracesboolean
tryFailure(java.lang.Throwable throwable)
Complete the promise abnormally if not already completeboolean
trySuccess(V v)
Complete the promise successfully if not already completestatic <V> SyncPromise<V>
uncancellable()
static <V> SyncPromise<V>
uncancellable(io.netty.util.concurrent.GenericFutureListener<? extends io.netty.util.concurrent.Future<? super V>> listener)
static <V> SyncPromise<V>
uncancellable(java.util.concurrent.Executor executor)
static <V> SyncPromise<V>
withExecutor(java.util.concurrent.Executor executor)
-
Methods inherited from class org.apache.cassandra.utils.concurrent.SyncFuture
awaitUntil, flatMap, map
-
Methods inherited from class org.apache.cassandra.utils.concurrent.AbstractFuture
addCallback, addCallback, addCallback, addListener, addListener, await, awaitThrowUncheckedOnInterrupt, awaitUninterruptibly, awaitUntilThrowUncheckedOnInterrupt, awaitUntilUninterruptibly, cancel, cause, description, flatMap, get, get, getNow, getWhenDone, isCancellable, isCancelled, isDone, isSuccess, map, map, notifyExecutor, toString
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.apache.cassandra.utils.concurrent.Awaitable
await, awaitThrowUncheckedOnInterrupt, awaitUninterruptibly, awaitUntil, awaitUntilThrowUncheckedOnInterrupt, awaitUntilUninterruptibly
-
Methods inherited from interface io.netty.util.concurrent.Future
await, awaitUninterruptibly, cancel, cause, getNow, isCancellable, isSuccess
-
Methods inherited from interface org.apache.cassandra.utils.concurrent.Future
addCallback, addCallback, addCallback, addListener, addListener, await, awaitUninterruptibly, flatMap, flatMap, map, map, notifyExecutor, rethrowIfFailed, syncThrowUncheckedOnInterrupt
-
-
-
-
Constructor Detail
-
SyncPromise
public SyncPromise()
-
SyncPromise
public SyncPromise(io.netty.util.concurrent.GenericFutureListener<? extends io.netty.util.concurrent.Future<? super V>> listener)
-
-
Method Detail
-
withExecutor
public static <V> SyncPromise<V> withExecutor(java.util.concurrent.Executor executor)
-
uncancellable
public static <V> SyncPromise<V> uncancellable()
-
uncancellable
public static <V> SyncPromise<V> uncancellable(java.util.concurrent.Executor executor)
-
uncancellable
public static <V> SyncPromise<V> uncancellable(io.netty.util.concurrent.GenericFutureListener<? extends io.netty.util.concurrent.Future<? super V>> listener)
-
setSuccess
public Promise<V> setSuccess(V v)
Complete the promise successfully if not already complete- Specified by:
setSuccess
in interfaceio.netty.util.concurrent.Promise<V>
- Specified by:
setSuccess
in interfacePromise<V>
- Throws:
java.lang.IllegalStateException
- if already set
-
trySuccess
public boolean trySuccess(V v)
Complete the promise successfully if not already complete- Specified by:
trySuccess
in interfaceio.netty.util.concurrent.Promise<V>
- Overrides:
trySuccess
in classAbstractFuture<V>
- Returns:
- true iff completed promise
-
setFailure
public Promise<V> setFailure(java.lang.Throwable throwable)
Complete the promise abnormally if not already complete- Specified by:
setFailure
in interfaceio.netty.util.concurrent.Promise<V>
- Specified by:
setFailure
in interfacePromise<V>
- Throws:
java.lang.IllegalStateException
- if already set
-
tryFailure
public boolean tryFailure(java.lang.Throwable throwable)
Complete the promise abnormally if not already complete- Specified by:
tryFailure
in interfaceio.netty.util.concurrent.Promise<V>
- Overrides:
tryFailure
in classAbstractFuture<V>
- Returns:
- true iff completed promise
-
setUncancellable
public boolean setUncancellable()
Prevent a future caller from cancelling this promise- Specified by:
setUncancellable
in interfaceio.netty.util.concurrent.Promise<V>
- Overrides:
setUncancellable
in classAbstractFuture<V>
- Returns:
- true if the promise is now uncancellable (whether or not we did this)
-
setUncancellableExclusive
public boolean setUncancellableExclusive()
Prevent a future caller from cancelling this promise- Specified by:
setUncancellableExclusive
in interfacePromise<V>
- Overrides:
setUncancellableExclusive
in classAbstractFuture<V>
- Returns:
- true iff this invocation set it to uncancellable, whether or not now uncancellable
-
isUncancellable
public boolean isUncancellable()
- Overrides:
isUncancellable
in classAbstractFuture<V>
-
sync
public Promise<V> sync() throws java.lang.InterruptedException
waits for completion; in case of failure rethrows the original exception without a new wrapping exception so may cause problems for reporting stack traces
-
syncUninterruptibly
public Promise<V> syncUninterruptibly()
waits for completion; in case of failure rethrows the original exception without a new wrapping exception so may cause problems for reporting stack traces- Specified by:
syncUninterruptibly
in interfaceio.netty.util.concurrent.Future<V>
- Specified by:
syncUninterruptibly
in interfaceFuture<V>
- Specified by:
syncUninterruptibly
in interfaceio.netty.util.concurrent.Promise<V>
- Specified by:
syncUninterruptibly
in interfacePromise<V>
-
addListener
public SyncPromise<V> addListener(io.netty.util.concurrent.GenericFutureListener<? extends io.netty.util.concurrent.Future<? super V>> listener)
Description copied from class:AbstractFuture
Add a listener to be invoked once this future completes. Listeners are submitted toAbstractFuture.notifyExecutor()
in the order they are added (or the specified executor in the case ofAbstractFuture.addListener(Runnable, Executor)
. ifAbstractFuture.notifyExecutor()
is unset, they are invoked in the order they are added. The ordering holds across all variants of this method.- Specified by:
addListener
in interfaceio.netty.util.concurrent.Future<V>
- Specified by:
addListener
in interfaceFuture<V>
- Specified by:
addListener
in interfaceio.netty.util.concurrent.Promise<V>
- Specified by:
addListener
in interfacePromise<V>
- Overrides:
addListener
in classAbstractFuture<V>
-
addListeners
public SyncPromise<V> addListeners(io.netty.util.concurrent.GenericFutureListener<? extends io.netty.util.concurrent.Future<? super V>>... listeners)
- Specified by:
addListeners
in interfaceio.netty.util.concurrent.Future<V>
- Specified by:
addListeners
in interfaceFuture<V>
- Specified by:
addListeners
in interfaceio.netty.util.concurrent.Promise<V>
- Specified by:
addListeners
in interfacePromise<V>
- Overrides:
addListeners
in classAbstractFuture<V>
-
removeListener
public SyncPromise<V> removeListener(io.netty.util.concurrent.GenericFutureListener<? extends io.netty.util.concurrent.Future<? super V>> listener)
- Specified by:
removeListener
in interfaceio.netty.util.concurrent.Future<V>
- Specified by:
removeListener
in interfaceFuture<V>
- Specified by:
removeListener
in interfaceio.netty.util.concurrent.Promise<V>
- Specified by:
removeListener
in interfacePromise<V>
- Overrides:
removeListener
in classAbstractFuture<V>
-
removeListeners
public SyncPromise<V> removeListeners(io.netty.util.concurrent.GenericFutureListener<? extends io.netty.util.concurrent.Future<? super V>>... listeners)
- Specified by:
removeListeners
in interfaceio.netty.util.concurrent.Future<V>
- Specified by:
removeListeners
in interfaceFuture<V>
- Specified by:
removeListeners
in interfaceio.netty.util.concurrent.Promise<V>
- Specified by:
removeListeners
in interfacePromise<V>
- Overrides:
removeListeners
in classAbstractFuture<V>
-
addCallback
public SyncPromise<V> addCallback(com.google.common.util.concurrent.FutureCallback<? super V> callback)
Description copied from class:AbstractFuture
SupportFutures.addCallback(com.google.common.util.concurrent.ListenableFuture<V>, com.google.common.util.concurrent.FutureCallback<? super V>, java.util.concurrent.Executor)
natively SeeAbstractFuture.addListener(GenericFutureListener)
for ordering semantics.- Specified by:
addCallback
in interfaceFuture<V>
- Specified by:
addCallback
in interfacePromise<V>
- Overrides:
addCallback
in classAbstractFuture<V>
-
addCallback
public SyncPromise<V> addCallback(com.google.common.util.concurrent.FutureCallback<? super V> callback, java.util.concurrent.Executor executor)
Description copied from class:AbstractFuture
SupportFutures.addCallback(com.google.common.util.concurrent.ListenableFuture<V>, com.google.common.util.concurrent.FutureCallback<? super V>, java.util.concurrent.Executor)
natively SeeAbstractFuture.addListener(GenericFutureListener)
for ordering semantics.- Specified by:
addCallback
in interfaceFuture<V>
- Specified by:
addCallback
in interfacePromise<V>
- Overrides:
addCallback
in classAbstractFuture<V>
-
addCallback
public SyncPromise<V> addCallback(java.util.function.Consumer<? super V> onSuccess, java.util.function.Consumer<? super java.lang.Throwable> onFailure)
Description copied from class:AbstractFuture
Support more fluid version ofFutures.addCallback(com.google.common.util.concurrent.ListenableFuture<V>, com.google.common.util.concurrent.FutureCallback<? super V>, java.util.concurrent.Executor)
SeeAbstractFuture.addListener(GenericFutureListener)
for ordering semantics.- Specified by:
addCallback
in interfaceFuture<V>
- Specified by:
addCallback
in interfacePromise<V>
- Overrides:
addCallback
in classAbstractFuture<V>
-
await
public SyncPromise<V> await() throws java.lang.InterruptedException
Wait for this promise to complete- Specified by:
await
in interfaceAwaitable
- Specified by:
await
in interfaceio.netty.util.concurrent.Future<V>
- Specified by:
await
in interfaceFuture<V>
- Specified by:
await
in interfaceio.netty.util.concurrent.Promise<V>
- Specified by:
await
in interfacePromise<V>
- Overrides:
await
in classSyncFuture<V>
- Throws:
java.lang.InterruptedException
- if interrupted
-
awaitUninterruptibly
public SyncPromise<V> awaitUninterruptibly()
Wait uninterruptibly for this promise to complete- Specified by:
awaitUninterruptibly
in interfaceAwaitable
- Specified by:
awaitUninterruptibly
in interfaceio.netty.util.concurrent.Future<V>
- Specified by:
awaitUninterruptibly
in interfaceFuture<V>
- Specified by:
awaitUninterruptibly
in interfaceio.netty.util.concurrent.Promise<V>
- Specified by:
awaitUninterruptibly
in interfacePromise<V>
- Overrides:
awaitUninterruptibly
in classAbstractFuture<V>
-
awaitThrowUncheckedOnInterrupt
public SyncPromise<V> awaitThrowUncheckedOnInterrupt() throws UncheckedInterruptedException
Wait for this promise to complete, throwing any interrupt as an UncheckedInterruptedException- Specified by:
awaitThrowUncheckedOnInterrupt
in interfaceAwaitable
- Specified by:
awaitThrowUncheckedOnInterrupt
in interfaceFuture<V>
- Specified by:
awaitThrowUncheckedOnInterrupt
in interfacePromise<V>
- Overrides:
awaitThrowUncheckedOnInterrupt
in classAbstractFuture<V>
- Throws:
UncheckedInterruptedException
- if interrupted
-
-