Package org.pipecraft.pipes.async.inter
Class AsyncUnionPipe<T>
- java.lang.Object
-
- org.pipecraft.pipes.async.AsyncPipe<T>
-
- org.pipecraft.pipes.async.inter.AsyncUnionPipe<T>
-
- All Implemented Interfaces:
Closeable,AutoCloseable,BasePipe
public class AsyncUnionPipe<T> extends AsyncPipe<T>
An intermediate async pipe fed by a set of other async pipes. This pipe passes on all events produced by the input pipes, on their original threads. It also takes care of detecting end of input properly. Serves in cases where we need a single async pipe as an input for some processing. Similar toSortedUnionPipe, but with no order sensitivity and no deduping option.- Author:
- Eyal Schneider
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.pipecraft.pipes.async.AsyncPipe
AsyncPipe.Status
-
-
Constructor Summary
Constructors Constructor Description AsyncUnionPipe(Collection<AsyncPipe<T>> inputPipes)Constructor
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()floatgetProgress()voidstart()Performs pre-processing prior to item flow throw the pipe.-
Methods inherited from class org.pipecraft.pipes.async.AsyncPipe
getStatus, notifyDone, notifyError, notifyNext, setListener
-
-
-
-
Constructor Detail
-
AsyncUnionPipe
public AsyncUnionPipe(Collection<AsyncPipe<T>> inputPipes)
Constructor- Parameters:
inputPipes- The input pipes to unify
-
-
Method Detail
-
start
public void start() throws PipeException, InterruptedExceptionDescription copied from interface:BasePipePerforms pre-processing prior to item flow throw the pipe. Implementations must call the same method for all their input pipes before accessing their items. This is typically done here.- Throws:
PipeException- In case of pipe errors in this pipe or somewhere up-stream.InterruptedException- In case that the operation has been interrupted by another thread.
-
getProgress
public float getProgress()
- Returns:
- The pipe flow progress, as a floating number between 0.0 and 1.0. Important implementation rules: 1) Calling this method before start() call is complete isn't allowed and has an undefined behavior. 2) Implementation should do best effort to provide an estimate of the progress this pipe has made (0.0 - 1.0) 3) When the pipe is fully consumed, getProgress() should return 1.0. 4) Results must be monotonous, i.e. results of consecutive calls may never be decreasing. 5) Thread safety: progress may be maintained by some thread/s but monitoring by other threads. Implementations must be thread safe.
-
close
public void close() throws IOException- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Overrides:
closein classAsyncPipe<T>- Throws:
IOException
-
-