public interface WorkProcessor<T>
| Modifier and Type | Interface and Description |
|---|---|
static interface |
WorkProcessor.Process<T> |
static class |
WorkProcessor.ProcessState<T> |
static interface |
WorkProcessor.Transformation<T,R> |
static class |
WorkProcessor.TransformationState<T> |
| Modifier and Type | Method and Description |
|---|---|
static <T> WorkProcessor<T> |
create(WorkProcessor.Process<T> process)
Creates
WorkProcessor from Process. |
default WorkProcessor<T> |
finishWhen(BooleanSupplier finishSignal) |
default <R> WorkProcessor<R> |
flatMap(Function<T,WorkProcessor<R>> mapper) |
static <T> WorkProcessor<T> |
flatten(WorkProcessor<WorkProcessor<T>> processor) |
default <R> WorkProcessor<R> |
flatTransform(WorkProcessor.Transformation<T,WorkProcessor<R>> transformation)
Flattens
WorkProcessors returned by transformation. |
static <T> WorkProcessor<T> |
fromIterable(Iterable<T> iterable) |
static <T> WorkProcessor<T> |
fromIterator(Iterator<T> iterator) |
com.google.common.util.concurrent.ListenableFuture<?> |
getBlockedFuture() |
T |
getResult()
Get the result once the unit of work is done and the processor hasn't finished.
|
boolean |
isBlocked() |
boolean |
isFinished() |
default Iterator<T> |
iterator()
Converts
WorkProcessor into an Iterator. |
default <R> WorkProcessor<R> |
map(Function<T,R> mapper) |
static <T> WorkProcessor<T> |
mergeSorted(Iterable<WorkProcessor<T>> processorIterable,
Comparator<T> comparator) |
static <T> WorkProcessor<T> |
of(T... elements) |
boolean |
process()
Call the method to progress the work.
|
default <R> WorkProcessor<R> |
transform(WorkProcessor.Transformation<T,R> transformation)
Transforms
WorkProcessor using WorkProcessor.Transformation. |
default <R> WorkProcessor<R> |
transformProcessor(Function<WorkProcessor<T>,WorkProcessor<R>> transformation) |
default WorkProcessor<T> |
withProcessEntryMonitor(Runnable monitor) |
default WorkProcessor<T> |
withProcessStateMonitor(Consumer<WorkProcessor.ProcessState<T>> monitor) |
default WorkProcessor<T> |
yielding(BooleanSupplier yieldSignal)
Makes
WorkProcessor yield when given yieldSignal is set. |
default Iterator<Optional<T>> |
yieldingIterator()
Converts
WorkProcessor into an yielding Iterator. |
boolean process()
getResult().
When this method returns false then the processor is either
blocked or has yielded.boolean isBlocked()
com.google.common.util.concurrent.ListenableFuture<?> getBlockedFuture()
isBlocked() returned true.boolean isFinished()
T getResult()
default WorkProcessor<T> yielding(BooleanSupplier yieldSignal)
WorkProcessor yield when given yieldSignal is set. The processor is
guaranteed to progress computations on subsequent process() calls
even if yieldSignal is permanently on.default WorkProcessor<T> withProcessEntryMonitor(Runnable monitor)
default WorkProcessor<T> withProcessStateMonitor(Consumer<WorkProcessor.ProcessState<T>> monitor)
default WorkProcessor<T> finishWhen(BooleanSupplier finishSignal)
default <R> WorkProcessor<R> flatMap(Function<T,WorkProcessor<R>> mapper)
default <R> WorkProcessor<R> map(Function<T,R> mapper)
default <R> WorkProcessor<R> flatTransform(WorkProcessor.Transformation<T,WorkProcessor<R>> transformation)
WorkProcessors returned by transformation. Each WorkProcessor produced
by transformation will be fully consumed before transformation is called again to produce more processors.default <R> WorkProcessor<R> transform(WorkProcessor.Transformation<T,R> transformation)
WorkProcessor using WorkProcessor.Transformation. WorkProcessor.Transformation instance will be dereferenced immediately after
WorkProcessor is exhausted.default <R> WorkProcessor<R> transformProcessor(Function<WorkProcessor<T>,WorkProcessor<R>> transformation)
default Iterator<T> iterator()
WorkProcessor into an Iterator. The iterator will throw IllegalStateException when underlying WorkProcessor
yields or becomes blocked. WorkProcessor instance will be dereferenced immediately after iterator is finished.default Iterator<Optional<T>> yieldingIterator()
WorkProcessor into an yielding Iterator. The iterator will throw IllegalStateException when underlying WorkProcessor
becomes blocked. WorkProcessor instance will be dereferenced immediately after iterator is exhausted.static <T> WorkProcessor<T> flatten(WorkProcessor<WorkProcessor<T>> processor)
@SafeVarargs static <T> WorkProcessor<T> of(T... elements)
static <T> WorkProcessor<T> fromIterable(Iterable<T> iterable)
static <T> WorkProcessor<T> fromIterator(Iterator<T> iterator)
static <T> WorkProcessor<T> create(WorkProcessor.Process<T> process)
WorkProcessor from Process. Process instance will be dereferenced immediately after WorkProcessor is finished.static <T> WorkProcessor<T> mergeSorted(Iterable<WorkProcessor<T>> processorIterable, Comparator<T> comparator)
Copyright © 2012–2019. All rights reserved.