Class AsyncGeneratorFlow.Generator<E>
java.lang.Object
org.bsc.async.AsyncGenerator.Base<E>
org.bsc.async.AsyncGenerator.BaseCancellable<E>
org.bsc.async.v5.AsyncGeneratorFlow.Generator<E>
- Type Parameters:
E- the type of elements in the queue
- All Implemented Interfaces:
AutoCloseable, Iterable<E>, AsyncGenerator<E>, AsyncGenerator.Cancellable<E>, AsyncGenerator.HasResultValue, AsyncGenerator.IsCancellable, AsyncGeneratorFlow.IsCancellableEx
- Enclosing interface:
AsyncGeneratorFlow
public static class AsyncGeneratorFlow.Generator<E>
extends AsyncGenerator.BaseCancellable<E>
implements AsyncGenerator.HasResultValue, AsyncGeneratorFlow.IsCancellableEx
Inner class to generate asynchronous elements from the queue.
-
Nested Class Summary
Nested classes/interfaces inherited from interface AsyncGenerator
AsyncGenerator.Base<E>, AsyncGenerator.BaseCancellable<E>, AsyncGenerator.Cancellable<E>, AsyncGenerator.Data<E>, AsyncGenerator.Embed<E>, AsyncGenerator.EmbedCompletionHandler, AsyncGenerator.HasResultValue, AsyncGenerator.IsCancellable, AsyncGenerator.ReduceResult<E>, AsyncGenerator.WithEmbed<E>, AsyncGenerator.WithResult<E>Nested classes/interfaces inherited from interface AsyncGeneratorFlow.IsCancellableEx
AsyncGeneratorFlow.IsCancellableEx.Listener, AsyncGeneratorFlow.IsCancellableEx.Registration -
Field Summary
Fields inherited from interface AsyncGenerator.IsCancellable
CANCELLED -
Method Summary
Modifier and TypeMethodDescriptionbooleancancel(boolean mayInterruptIfRunning) Once the last element has been returned, a cancel keeps the result and does not reach the generators linked withAsyncGeneratorFlow.Builder.cancelledBy(AsyncGeneratorFlow.IsCancellableEx).voidclose()Closes this AsyncGenerator and releases its resources.next()Retrieves the next element from the queue asynchronously.Calls the listener right away if already cancelled.receiver()Methods inherited from class AsyncGenerator.BaseCancellable
isCancelledMethods inherited from class AsyncGenerator.Base
executor, isClosedMethods inherited from class Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface AsyncGenerator
executor, flatMap, forEachAsync, iterator, map, reduce, reduce, reduceAsync, reduceAsync, stream, toCompletableFuture, toCompletableFutureAsyncMethods inherited from interface AsyncGenerator.IsCancellable
isCancelledMethods inherited from interface Iterable
forEach, spliterator
-
Method Details
-
receiver
-
next
Retrieves the next element from the queue asynchronously.- Specified by:
nextin interfaceAsyncGenerator<E>- Returns:
- the next element from the queue
-
cancel
public boolean cancel(boolean mayInterruptIfRunning) Once the last element has been returned, a cancel keeps the result and does not reach the generators linked withAsyncGeneratorFlow.Builder.cancelledBy(AsyncGeneratorFlow.IsCancellableEx).- Specified by:
cancelin interfaceAsyncGenerator.IsCancellable- Overrides:
cancelin classAsyncGenerator.BaseCancellable<E>- Parameters:
mayInterruptIfRunning- iftrue, interrupt running tasks- Returns:
trueif cancellation was successful,falseif already cancelled
-
onCancel
public AsyncGeneratorFlow.IsCancellableEx.Registration onCancel(AsyncGeneratorFlow.IsCancellableEx.Listener listener) Description copied from interface:AsyncGeneratorFlow.IsCancellableExCalls the listener right away if already cancelled.- Specified by:
onCancelin interfaceAsyncGeneratorFlow.IsCancellableEx
-
close
public void close()Description copied from class:AsyncGenerator.BaseCloses this AsyncGenerator and releases its resources.This method shuts down the internal ExecutorService. After calling this method, the generator should not be used for further operations.
This method is idempotent - calling it multiple times has no additional effect.
- Specified by:
closein interfaceAutoCloseable- Overrides:
closein classAsyncGenerator.Base<E>
-
resultValue
- Specified by:
resultValuein interfaceAsyncGenerator.HasResultValue
-