Class CancellableExecutor
java.lang.Object
org.bsc.async.executor.CancellableExecutor
- All Implemented Interfaces:
Executor, AsyncGenerator.IsCancellable
Runs tasks on a borrowed
Executor, which it never shuts down. Once cancelled it skips the tasks not started
yet, so a future over one of them never completes.-
Nested Class Summary
Nested Classes -
Field Summary
Fields inherited from interface AsyncGenerator.IsCancellable
CANCELLED -
Method Summary
Modifier and TypeMethodDescription<T> TAny cancel, with or without interrupt, ends the call with anInterruptedException.booleancancel(boolean mayInterruptIfRunning) method that request to cancel generatorvoidbooleanChecks if the asynchronous generation has been cancelled.static CancellableExecutor
-
Method Details
-
of
-
execute
-
callUntilCancelled
public <T> T callUntilCancelled(CancellableExecutor.BlockingCall<T> call) throws InterruptedException Any cancel, with or without interrupt, ends the call with anInterruptedException.- Throws:
InterruptedException
-
isCancelled
public boolean isCancelled()Description copied from interface:AsyncGenerator.IsCancellableChecks if the asynchronous generation has been cancelled.The default implementation always returns
false. Implementations that support cancellation should override this method.- Specified by:
isCancelledin interfaceAsyncGenerator.IsCancellable- Returns:
trueif the generator has been cancelled,falseotherwise.
-
cancel
public boolean cancel(boolean mayInterruptIfRunning) Description copied from interface:AsyncGenerator.IsCancellablemethod that request to cancel generator- Specified by:
cancelin interfaceAsyncGenerator.IsCancellable
-