public abstract class Dataflow
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static java.lang.ThreadLocal<PGroup> |
activeParallelGroup
Maps threads/tasks to parallel groups they belong to
|
static PGroup |
DATA_FLOW_GROUP
The parallel group used by all Dataflow Concurrency actors by default.
|
Constructor and Description |
---|
Dataflow() |
Modifier and Type | Method and Description |
---|---|
static <T> Promise<T> |
lazyTask(java.util.concurrent.Callable<T> callable)
Creates a new task assigned to a thread from the current parallel group.
|
static <T> Promise<T> |
lazyTask(groovy.lang.Closure<T> code)
Creates a new task assigned to a thread from the default dataflow parallel group.
|
static DataflowProcessor |
operator(DataflowReadChannel input,
DataflowWriteChannel output,
groovy.lang.Closure code)
Creates an operator using the current parallel group
|
static DataflowProcessor |
operator(DataflowReadChannel input,
DataflowWriteChannel output,
int maxForks,
groovy.lang.Closure code)
Creates an operator using the current parallel group
|
static DataflowProcessor |
operator(java.util.List inputChannels,
java.util.List outputChannels,
groovy.lang.Closure code)
Creates an operator using the current parallel group
|
static DataflowProcessor |
operator(java.util.List inputChannels,
java.util.List outputChannels,
int maxForks,
groovy.lang.Closure code)
Creates an operator using the current parallel group
|
static DataflowProcessor |
operator(java.util.Map channels,
groovy.lang.Closure code)
Creates an operator using the default dataflow parallel group
|
static DataflowProcessor |
prioritySelector(java.util.List inputChannels,
java.util.List outputChannels)
Creates a prioritizing selector using the default dataflow parallel group.
|
static DataflowProcessor |
prioritySelector(java.util.List inputChannels,
java.util.List outputChannels,
groovy.lang.Closure code)
Creates a prioritizing selector using the default dataflow parallel group
Input with lower position index have higher priority.
|
static DataflowProcessor |
prioritySelector(java.util.Map channels)
Creates a prioritizing selector using the default dataflow parallel group.
|
static DataflowProcessor |
prioritySelector(java.util.Map channels,
groovy.lang.Closure code)
Creates a prioritizing selector using the default dataflow parallel group
Input with lower position index have higher priority.
|
static PGroup |
retrieveCurrentDFPGroup()
Retrieves the thread-local value of the active PGroup or the default DataflowGroup
|
static Select<?> |
select(java.util.List<SelectableChannel> channels)
Creates a select using the default dataflow parallel group.
|
static Select<?> |
select(SelectableChannel<?>... channels)
Creates a select using the default dataflow parallel group.
|
static DataflowProcessor |
selector(java.util.List inputChannels,
java.util.List outputChannels)
Creates a selector using the default dataflow parallel group.
|
static DataflowProcessor |
selector(java.util.List inputChannels,
java.util.List outputChannels,
groovy.lang.Closure code)
Creates a selector using the default dataflow parallel group
|
static DataflowProcessor |
selector(java.util.Map channels)
Creates a selector using the default dataflow parallel group.
|
static DataflowProcessor |
selector(java.util.Map channels,
groovy.lang.Closure code)
Creates a selector using the default dataflow parallel group
|
static DataflowProcessor |
splitter(DataflowReadChannel inputChannel,
java.util.List<DataflowWriteChannel> outputChannels)
Creates a splitter copying its single input channel into all of its output channels.
|
static DataflowProcessor |
splitter(DataflowReadChannel inputChannel,
java.util.List<DataflowWriteChannel> outputChannels,
int maxForks)
Creates a splitter copying its single input channel into all of its output channels.
|
static <T> Promise<T> |
task(java.util.concurrent.Callable<T> callable)
Creates a new task assigned to a thread from the current parallel group.
|
static <T> Promise<T> |
task(groovy.lang.Closure<T> code)
Creates a new task assigned to a thread from the default dataflow parallel group.
|
static Promise<java.lang.Object> |
task(java.lang.Runnable runnable)
Creates a new task assigned to a thread from the current parallel group.
|
static java.lang.Object |
usingGroup(PGroup group,
groovy.lang.Closure code)
Sets the supplied PGroup as the default for the given block of code.
|
static <T> Promise<T> |
whenAllBound(java.util.List<Promise> promises,
groovy.lang.Closure<T> code)
Without blocking the thread waits for all the promises to get bound and then passes them to the supplied closure.
|
static <T> Promise<T> |
whenAllBound(java.util.List<Promise> promises,
groovy.lang.Closure<T> code,
groovy.lang.Closure<T> errorHandler)
Without blocking the thread waits for all the promises to get bound and then passes them to the supplied closure.
|
static <T> Promise<T> |
whenAllBound(Promise promise1,
groovy.lang.Closure<T> code)
Without blocking the thread waits for all the promises to get bound and then passes them to the supplied closure.
|
static <T> Promise<T> |
whenAllBound(Promise promise1,
groovy.lang.Closure<T> code,
groovy.lang.Closure<T> errorHandler)
Without blocking the thread waits for all the promises to get bound and then passes them to the supplied closure.
|
static <T> Promise<T> |
whenAllBound(Promise promise1,
Promise promise2,
groovy.lang.Closure<T> code)
Without blocking the thread waits for all the promises to get bound and then passes them to the supplied closure.
|
static <T> Promise<T> |
whenAllBound(Promise promise1,
Promise promise2,
groovy.lang.Closure<T> code,
groovy.lang.Closure<T> errorHandler)
Without blocking the thread waits for all the promises to get bound and then passes them to the supplied closure.
|
static <T> Promise<T> |
whenAllBound(Promise promise1,
Promise promise2,
Promise promise3,
groovy.lang.Closure<T> code)
Without blocking the thread waits for all the promises to get bound and then passes them to the supplied closure.
|
static <T> Promise<T> |
whenAllBound(Promise promise1,
Promise promise2,
Promise promise3,
groovy.lang.Closure<T> code,
groovy.lang.Closure<T> errorHandler)
Without blocking the thread waits for all the promises to get bound and then passes them to the supplied closure.
|
static <T> Promise<T> |
whenAllBound(Promise promise1,
Promise promise2,
Promise promise3,
Promise promise4,
groovy.lang.Closure<T> code)
Without blocking the thread waits for all the promises to get bound and then passes them to the supplied closure.
|
static <T> Promise<T> |
whenAllBound(Promise promise1,
Promise promise2,
Promise promise3,
Promise promise4,
groovy.lang.Closure<T> code,
groovy.lang.Closure<T> errorHandler)
Without blocking the thread waits for all the promises to get bound and then passes them to the supplied closure.
|
public static final PGroup DATA_FLOW_GROUP
public static final java.lang.ThreadLocal<PGroup> activeParallelGroup
public static PGroup retrieveCurrentDFPGroup()
public static java.lang.Object usingGroup(PGroup group, groovy.lang.Closure code)
group
- The group to make the default inside the blockcode
- The code to run with overriden defaultpublic static <T> Promise<T> task(groovy.lang.Closure<T> code)
code
- The task body to runpublic static <T> Promise<T> task(java.util.concurrent.Callable<T> callable)
callable
- The task body to runpublic static Promise<java.lang.Object> task(java.lang.Runnable runnable)
runnable
- The task body to runpublic static <T> Promise<T> lazyTask(groovy.lang.Closure<T> code)
code
- The task body to runpublic static <T> Promise<T> lazyTask(java.util.concurrent.Callable<T> callable)
callable
- The task body to runpublic static DataflowProcessor operator(java.util.Map channels, @DelegatesTo(value=DataflowOperator.class) groovy.lang.Closure code)
channels
- A map specifying "inputs" and "outputs" - dataflow channels (instances of the DataflowQueue or DataflowVariable classes) to use for inputs and outputscode
- The operator's body to run each time all inputs have a value to readpublic static DataflowProcessor operator(java.util.List inputChannels, java.util.List outputChannels, @DelegatesTo(value=DataflowOperator.class) groovy.lang.Closure code)
inputChannels
- dataflow channels to use for inputoutputChannels
- dataflow channels to use for outputcode
- The operator's body to run each time all inputs have a value to readpublic static DataflowProcessor operator(java.util.List inputChannels, java.util.List outputChannels, int maxForks, @DelegatesTo(value=DataflowOperator.class) groovy.lang.Closure code)
inputChannels
- dataflow channels to use for inputoutputChannels
- dataflow channels to use for outputmaxForks
- Number of parallel threads running operator's body, defaults to 1code
- The operator's body to run each time all inputs have a value to readpublic static DataflowProcessor operator(DataflowReadChannel input, DataflowWriteChannel output, @DelegatesTo(value=DataflowOperator.class) groovy.lang.Closure code)
input
- a dataflow channel to use for inputoutput
- a dataflow channel to use for outputcode
- The operator's body to run each time all inputs have a value to readpublic static DataflowProcessor operator(DataflowReadChannel input, DataflowWriteChannel output, int maxForks, @DelegatesTo(value=DataflowOperator.class) groovy.lang.Closure code)
input
- a dataflow channel to use for inputoutput
- a dataflow channel to use for outputmaxForks
- Number of parallel threads running operator's body, defaults to 1code
- The operator's body to run each time all inputs have a value to readpublic static DataflowProcessor selector(java.util.Map channels, @DelegatesTo(value=DataflowSelector.class) groovy.lang.Closure code)
channels
- A map specifying "inputs" and "outputs" - dataflow channels (instances of the DataflowQueue or DataflowVariable classes) to use for inputs and outputscode
- The selector's body to run each time a value is available in any of the inputs channelspublic static DataflowProcessor selector(java.util.List inputChannels, java.util.List outputChannels, @DelegatesTo(value=DataflowSelector.class) groovy.lang.Closure code)
inputChannels
- dataflow channels to use for inputoutputChannels
- dataflow channels to use for outputcode
- The selector's body to run each time a value is available in any of the inputs channelspublic static DataflowProcessor selector(java.util.Map channels)
channels
- A map specifying "inputs" and "outputs" - dataflow channels (instances of the DataflowQueue or DataflowVariable classes) to use for inputs and outputspublic static DataflowProcessor selector(java.util.List inputChannels, java.util.List outputChannels)
inputChannels
- dataflow channels to use for inputoutputChannels
- dataflow channels to use for outputpublic static DataflowProcessor prioritySelector(java.util.Map channels, @DelegatesTo(value=DataflowSelector.class) groovy.lang.Closure code)
channels
- A map specifying "inputs" and "outputs" - dataflow channels (instances of the DataflowQueue or DataflowVariable classes) to use for inputs and outputscode
- The selector's body to run each time a value is available in any of the inputs channelspublic static DataflowProcessor prioritySelector(java.util.List inputChannels, java.util.List outputChannels, @DelegatesTo(value=DataflowSelector.class) groovy.lang.Closure code)
inputChannels
- dataflow channels to use for inputoutputChannels
- dataflow channels to use for outputcode
- The selector's body to run each time a value is available in any of the inputs channelspublic static DataflowProcessor prioritySelector(java.util.Map channels)
channels
- A map specifying "inputs" and "outputs" - dataflow channels (instances of the DataflowQueue or DataflowVariable classes) to use for inputs and outputspublic static DataflowProcessor prioritySelector(java.util.List inputChannels, java.util.List outputChannels)
inputChannels
- dataflow channels to use for inputoutputChannels
- dataflow channels to use for outputpublic static DataflowProcessor splitter(DataflowReadChannel inputChannel, java.util.List<DataflowWriteChannel> outputChannels)
inputChannel
- The channel to read values fromoutputChannels
- A list of channels to output topublic static DataflowProcessor splitter(DataflowReadChannel inputChannel, java.util.List<DataflowWriteChannel> outputChannels, int maxForks)
inputChannel
- The channel to read values fromoutputChannels
- A list of channels to output tomaxForks
- Number of threads running the splitter's body, defaults to 1public static Select<?> select(SelectableChannel<?>... channels)
channels
- Dataflow variables or streams to wait for values onpublic static Select<?> select(java.util.List<SelectableChannel> channels)
channels
- Dataflow variables or streams to wait for values onpublic static <T> Promise<T> whenAllBound(java.util.List<Promise> promises, groovy.lang.Closure<T> code)
T
- The type of the final resultpromises
- The promises to wait forcode
- A closure to execute with concrete values for each of the supplied promisespublic static <T> Promise<T> whenAllBound(Promise promise1, groovy.lang.Closure<T> code)
T
- The type of the final resultpromise1
- The promises to wait forcode
- A closure to execute with concrete values for each of the supplied promisespublic static <T> Promise<T> whenAllBound(Promise promise1, Promise promise2, groovy.lang.Closure<T> code)
T
- The type of the final resultpromise1
- The promises to wait forpromise2
- The promises to wait forcode
- A closure to execute with concrete values for each of the supplied promisespublic static <T> Promise<T> whenAllBound(Promise promise1, Promise promise2, Promise promise3, groovy.lang.Closure<T> code)
T
- The type of the final resultpromise1
- The promises to wait forpromise2
- The promises to wait forpromise3
- The promises to wait forcode
- A closure to execute with concrete values for each of the supplied promisespublic static <T> Promise<T> whenAllBound(Promise promise1, Promise promise2, Promise promise3, Promise promise4, groovy.lang.Closure<T> code)
T
- The type of the final resultpromise1
- The promises to wait forpromise2
- The promises to wait forpromise3
- The promises to wait forpromise4
- The promises to wait forcode
- A closure to execute with concrete values for each of the supplied promisespublic static <T> Promise<T> whenAllBound(java.util.List<Promise> promises, groovy.lang.Closure<T> code, groovy.lang.Closure<T> errorHandler)
T
- The type of the final resultpromises
- The promises to wait forcode
- A closure to execute with concrete values for each of the supplied promiseserrorHandler
- A closure handling an exception (an instance of Throwable), if it gets boundpublic static <T> Promise<T> whenAllBound(Promise promise1, groovy.lang.Closure<T> code, groovy.lang.Closure<T> errorHandler)
T
- The type of the final resultpromise1
- The promises to wait forcode
- A closure to execute with concrete values for each of the supplied promiseserrorHandler
- A closure handling an exception (an instance of Throwable), if it gets boundpublic static <T> Promise<T> whenAllBound(Promise promise1, Promise promise2, groovy.lang.Closure<T> code, groovy.lang.Closure<T> errorHandler)
T
- The type of the final resultpromise1
- The promises to wait forpromise2
- The promises to wait forcode
- A closure to execute with concrete values for each of the supplied promiseserrorHandler
- A closure handling an exception (an instance of Throwable), if it gets boundpublic static <T> Promise<T> whenAllBound(Promise promise1, Promise promise2, Promise promise3, groovy.lang.Closure<T> code, groovy.lang.Closure<T> errorHandler)
T
- The type of the final resultpromise1
- The promises to wait forpromise2
- The promises to wait forpromise3
- The promises to wait forcode
- A closure to execute with concrete values for each of the supplied promiseserrorHandler
- A closure handling an exception (an instance of Throwable), if it gets boundpublic static <T> Promise<T> whenAllBound(Promise promise1, Promise promise2, Promise promise3, Promise promise4, groovy.lang.Closure<T> code, groovy.lang.Closure<T> errorHandler)
T
- The type of the final resultpromise1
- The promises to wait forpromise2
- The promises to wait forpromise3
- The promises to wait forpromise4
- The promises to wait forcode
- A closure to execute with concrete values for each of the supplied promiseserrorHandler
- A closure handling an exception (an instance of Throwable), if it gets bound