|
org.codehaus.gpars | |||||||
FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object groovyx.gpars.group.PGroup
@java.lang.SuppressWarnings* Creates a group for actors, agents, tasks and operators. The actors will share a common daemon thread pool. public abstract class PGroup
Provides a common super class of pooled parallel groups.
Field Summary | |
---|---|
protected static java.lang.String |
A_SPLITTER_NEEDS_AN_INPUT_CHANNEL_AND_AT_LEAST_ONE_OUTPUT_CHANNEL_TO_BE_CREATED
|
private Pool |
threadPool
|
Constructor Summary | |
protected PGroup(Pool threadPool)
|
Method Summary | |
---|---|
DefaultActor
|
actor(java.lang.Runnable handler)
Creates a new instance of BlockingActor, using the passed-in closure as the body of the actor's act() method. |
Agent
|
agent(java.lang.Object state)
Creates an agent instance initialized with the given state |
Agent
|
agent(java.lang.Object state, groovy.lang.Closure copy)
Creates an agent instance initialized with the given state, which will cooperate in thread sharing with other agents and actors in a fair manner. |
BlockingActor
|
blockingActor(java.lang.Runnable handler)
Creates a new instance of DefaultActor, using the passed-in runnable/closure as the body of the actor's act() method. |
void
|
execute(java.lang.Runnable task)
|
DefaultActor
|
fairActor(java.lang.Runnable handler)
|
Agent
|
fairAgent(java.lang.Object state)
Creates an agent instance initialized with the given state, which will cooperate in thread sharing with other agents and actors in a fair manner. |
Agent
|
fairAgent(java.lang.Object state, groovy.lang.Closure copy)
Creates a new task assigned to a thread from the current parallel group. |
Actor
|
fairMessageHandler(groovy.lang.Closure code)
Creates an instance of StaticDispatchActor. |
Actor
|
fairReactor(groovy.lang.Closure code)
Creates an instance of DynamicDispatchActor. |
Actor
|
fairStaticMessageHandler(groovy.lang.Closure code)
|
protected void
|
finalize()
|
int
|
getPoolSize()
Gently stops the pool |
Pool
|
getThreadPool()
|
private static boolean
|
isListAccepting(groovy.lang.Closure code)
|
Promise
|
lazyTask(groovy.lang.Closure code)
Creates a new task assigned to a thread from the current parallel group. |
Promise
|
lazyTask(java.util.concurrent.Callable callable)
|
Actor
|
messageHandler(groovy.lang.Closure code)
Creates an instance of DynamicDispatchActor, which will cooperate in thread sharing with other actors sharing the same thread pool |
DataflowProcessor
|
operator(java.util.Map channels, groovy.lang.Closure code)
Creates an operator using the current parallel group |
DataflowProcessor
|
operator(java.util.List inputChannels, java.util.List outputChannels, groovy.lang.Closure code)
Creates an operator using the current parallel group |
DataflowProcessor
|
operator(java.util.List inputChannels, java.util.List outputChannels, int maxForks, groovy.lang.Closure code)
Creates an operator using the current parallel group |
DataflowProcessor
|
operator(DataflowReadChannel input, DataflowWriteChannel output, groovy.lang.Closure code)
Creates an operator using the current parallel group |
DataflowProcessor
|
operator(DataflowReadChannel input, DataflowWriteChannel output, int maxForks, groovy.lang.Closure code)
Creates a selector using this parallel group |
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. |
DataflowProcessor
|
prioritySelector(java.util.List inputChannels, java.util.List outputChannels, groovy.lang.Closure code)
Creates a prioritizing selector using the default dataflow parallel group. |
DataflowProcessor
|
prioritySelector(java.util.Map channels)
Creates a prioritizing selector using the default dataflow parallel group. |
DataflowProcessor
|
prioritySelector(java.util.List inputChannels, java.util.List outputChannels)
Creates a splitter copying its single input channel into all of its output channels. |
Actor
|
reactor(groovy.lang.Closure code)
Creates a reactor around the supplied code, which will cooperate in thread sharing with other actors sharing the same thread pool When a reactor receives a message, the supplied block of code is run with the message as a parameter and the result of the code is send in reply. |
void
|
resetDefaultSize()
|
void
|
resize(int poolSize)
Sets the pool size to the default |
Select
|
select(SelectableChannel... channels)
Creates a select using the current parallel group. |
Select
|
select(java.util.List channels)
|
DataflowProcessor
|
selector(java.util.Map channels, groovy.lang.Closure code)
Creates a selector using this parallel group |
DataflowProcessor
|
selector(java.util.List inputChannels, java.util.List outputChannels, groovy.lang.Closure code)
Creates a selector using this parallel group. |
DataflowProcessor
|
selector(java.util.Map channels)
Creates a selector using this parallel group. |
DataflowProcessor
|
selector(java.util.List inputChannels, java.util.List outputChannels)
Creates a prioritizing selector using the default dataflow parallel group Input with lower position index have higher priority. |
private boolean
|
shallHandle(groovy.lang.Closure errorHandler, java.lang.Throwable e)
Shutdown the thread pool gracefully |
void
|
shutdown()
|
DataflowProcessor
|
splitter(DataflowReadChannel inputChannel, java.util.List outputChannels)
|
DataflowProcessor
|
splitter(DataflowReadChannel inputChannel, java.util.List outputChannels, int maxForks)
Creates a select using the current parallel group. |
Actor
|
staticMessageHandler(groovy.lang.Closure code)
|
Promise
|
task(groovy.lang.Closure code)
|
Promise
|
task(java.util.concurrent.Callable callable)
|
Promise
|
task(java.lang.Runnable code)
Creates a new task assigned to a thread from the current parallel group. |
Promise
|
whenAllBound(java.util.List promises, groovy.lang.Closure code)
Without blocking the thread waits for all the promises to get bound and then passes them to the supplied closure. |
Promise
|
whenAllBound(Promise promise1, groovy.lang.Closure code)
Without blocking the thread waits for all the promises to get bound and then passes them to the supplied closure. |
Promise
|
whenAllBound(Promise promise1, Promise promise2, groovy.lang.Closure code)
Without blocking the thread waits for all the promises to get bound and then passes them to the supplied closure. |
Promise
|
whenAllBound(Promise promise1, Promise promise2, Promise promise3, groovy.lang.Closure code)
Without blocking the thread waits for all the promises to get bound and then passes them to the supplied closure. |
Promise
|
whenAllBound(Promise promise1, Promise promise2, Promise promise3, Promise promise4, groovy.lang.Closure code)
Without blocking the thread waits for all the promises to get bound and then passes them to the supplied closure. |
Promise
|
whenAllBound(java.util.List promises, groovy.lang.Closure code, groovy.lang.Closure errorHandler)
|
Promise
|
whenAllBound(Promise promise1, groovy.lang.Closure code, groovy.lang.Closure errorHandler)
Without blocking the thread waits for all the promises to get bound and then passes them to the supplied closure. |
Promise
|
whenAllBound(Promise promise1, Promise promise2, groovy.lang.Closure code, groovy.lang.Closure errorHandler)
Without blocking the thread waits for all the promises to get bound and then passes them to the supplied closure. |
Promise
|
whenAllBound(Promise promise1, Promise promise2, Promise promise3, groovy.lang.Closure code, groovy.lang.Closure errorHandler)
Without blocking the thread waits for all the promises to get bound and then passes them to the supplied closure. |
Promise
|
whenAllBound(Promise promise1, Promise promise2, Promise promise3, Promise promise4, groovy.lang.Closure code, groovy.lang.Closure errorHandler)
Waits for the promise identified by the index to be bound and then passes on to the next promise in the list |
private void
|
whenAllBound(java.util.List promises, int index, java.util.List values, DataflowVariable result, groovy.lang.Closure code, groovy.lang.Closure errorHandler)
|
Methods inherited from class java.lang.Object | |
---|---|
java.lang.Object#wait(long, int), java.lang.Object#wait(long), java.lang.Object#wait(), java.lang.Object#equals(java.lang.Object), java.lang.Object#toString(), java.lang.Object#hashCode(), java.lang.Object#getClass(), java.lang.Object#notify(), java.lang.Object#notifyAll() |
Field Detail |
---|
protected static final java.lang.String A_SPLITTER_NEEDS_AN_INPUT_CHANNEL_AND_AT_LEAST_ONE_OUTPUT_CHANNEL_TO_BE_CREATED
private final Pool threadPool
Constructor Detail |
---|
protected PGroup(Pool threadPool)
Method Detail |
---|
public final DefaultActor actor(@groovy.lang.DelegatesTonew RunnableBackedBlockingActor(h java.lang.Runnable handler)
handler
- The body of the newly created actor's act method.
public final Agent agent(java.lang.Object state)
state
- The initial internal state of the new Agent instance
public final Agent agent(java.lang.Object state, groovy.lang.Closure copy)
state
- The initial internal state of the new Agent instance
public final BlockingActor blockingActor(@groovy.lang.DelegatesTogatesTo(DefaultActor.class) final java.lang.Runnable handler)
handler
- The body of the newly created actor's act method.
public void execute(java.lang.Runnable task)
public final DefaultActor fairActor(@groovy.lang.DelegatesTo java.lang.Runnable handler)
public final Agent fairAgent(java.lang.Object state)
copy
- A closure to use to create a copy of the internal state when sending the internal state outstate
- The initial internal state of the new Agent instance
public final Agent fairAgent(java.lang.Object state, groovy.lang.Closure copy)
code
- The task body to run
public final Actor fairMessageHandler(@groovy.lang.DelegatesToactor = new StaticDispatch groovy.lang.Closure code)
code
- The closure specifying the only statically dispatched message handler.
public final Actor fairReactor(@groovy.lang.DelegatesToactor = new DynamicDispatc groovy.lang.Closure code)
code
- The closure specifying individual message handlers.
public final Actor fairStaticMessageHandler(@groovy.lang.DelegatesTo groovy.lang.Closure code)
@java.lang.SuppressWarnings/** @java.lang.Override* Sets the pool size to the default protected void finalize()
public int getPoolSize()
public Pool getThreadPool()
private static boolean isListAccepting(groovy.lang.Closure code)
public final Promise lazyTask(groovy.lang.Closure code)
code
- The task body to run
public final Promise lazyTask(java.util.concurrent.Callable callable)
public final Actor messageHandler(@groovy.lang.DelegatesTo groovy.lang.Closure code)
code
- The closure specifying individual message handlers.
public final DataflowProcessor operator(java.util.Map channels, @groovy.lang.DelegatesTo 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 read
public final DataflowProcessor operator(java.util.List inputChannels, java.util.List outputChannels, @groovy.lang.DelegatesTofinal int maxForks, (Data 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 read
public final DataflowProcessor operator(java.util.List inputChannels, java.util.List outputChannels, int maxForks, @groovy.lang.DelegatesTogatesTo(DataflowOperator.class) final 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 read
public final DataflowProcessor operator(DataflowReadChannel input, DataflowWriteChannel output, @groovy.lang.DelegatesTofinal int maxForks, (Data 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 read
public final DataflowProcessor operator(DataflowReadChannel input, DataflowWriteChannel output, int maxForks, @groovy.lang.DelegatesTo 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 channels
public final DataflowProcessor prioritySelector(java.util.Map channels, @groovy.lang.DelegatesTo 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 channels
public final DataflowProcessor prioritySelector(java.util.List inputChannels, java.util.List outputChannels, @groovy.lang.DelegatesTo 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 outputs
public final DataflowProcessor prioritySelector(java.util.Map channels)
inputChannels
- dataflow channels to use for inputoutputChannels
- dataflow channels to use for output
public final DataflowProcessor prioritySelector(java.util.List inputChannels, java.util.List outputChannels)
inputChannel
- The channel to read values fromoutputChannels
- A list of channels to output to
public final Actor reactor(@groovy.lang.DelegatesTotor((Actor.cla groovy.lang.Closure code)
code
- The code to invoke for each received message
public void resetDefaultSize()
public void resize(int poolSize)
public final Select select(SelectableChannel... channels)
channels
- Dataflow variables or streams to wait for values on
public final Select select(java.util.List channels)
public final DataflowProcessor selector(java.util.Map channels, @groovy.lang.DelegatesTo 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 channels
public final DataflowProcessor selector(java.util.List inputChannels, java.util.List outputChannels, @groovy.lang.DelegatesTo 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 outputs
public final DataflowProcessor selector(java.util.Map channels)
inputChannels
- dataflow channels to use for inputoutputChannels
- dataflow channels to use for output
public final DataflowProcessor selector(java.util.List inputChannels, java.util.List outputChannels)
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 channels
private boolean shallHandle(groovy.lang.Closure errorHandler, java.lang.Throwable e)
public void shutdown()
public final DataflowProcessor splitter(DataflowReadChannel inputChannel, java.util.List outputChannels)
public final DataflowProcessor splitter(DataflowReadChannel inputChannel, java.util.List outputChannels, int maxForks)
channels
- Dataflow variables or streams to wait for values on
public final Actor staticMessageHandler(@groovy.lang.DelegatesToActor, which will cooperat groovy.lang.Closure code)
public final Promise task(groovy.lang.Closure code)
public final Promise task(java.util.concurrent.Callable callable)
public final Promise task(java.lang.Runnable code)
code
- The task body to run
public final Promise whenAllBound(java.util.List promises, groovy.lang.Closure code)
promise1
- The promises to wait forcode
- A closure to execute with concrete values for each of the supplied promises
- The type of the final result
public final Promise whenAllBound(Promise promise1, groovy.lang.Closure code)
promise1
- The promises to wait forpromise2
- The promises to wait forcode
- A closure to execute with concrete values for each of the supplied promises
- The type of the final result
public final Promise whenAllBound(Promise promise1, Promise promise2, groovy.lang.Closure code)
promise1
- 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 promises
- The type of the final result
public final Promise whenAllBound(Promise promise1, Promise promise2, Promise promise3, groovy.lang.Closure code)
promise1
- 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 promises
- The type of the final result
public final Promise whenAllBound(Promise promise1, Promise promise2, Promise promise3, Promise promise4, groovy.lang.Closure code)
promises
- 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
- The type of the final result
public final Promise whenAllBound(java.util.List promises, groovy.lang.Closure code, groovy.lang.Closure errorHandler)
public final Promise whenAllBound(Promise promise1, groovy.lang.Closure code, groovy.lang.Closure errorHandler)
promise1
- 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 if it gets bound
- The type of the final result
public final Promise whenAllBound(Promise promise1, Promise promise2, groovy.lang.Closure code, groovy.lang.Closure errorHandler)
promise1
- 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 if it gets bound
- The type of the final result
public final Promise whenAllBound(Promise promise1, Promise promise2, Promise promise3, groovy.lang.Closure code, groovy.lang.Closure errorHandler)
promise1
- 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 if it gets bound
- The type of the final result
public final Promise whenAllBound(Promise promise1, Promise promise2, Promise promise3, Promise promise4, groovy.lang.Closure code, groovy.lang.Closure errorHandler)
promises
- A list of all promises that need to be waited forindex
- The index of the current promise to wait forvalues
- A list of values the so-far processed promises were bound tporesult
- The promise for the final result of the calculationcode
- The calculation to execute on the values once they are all bound
- The type of the final result
private void whenAllBound(java.util.List promises, int index, java.util.List values, DataflowVariable result, groovy.lang.Closure code, groovy.lang.Closure errorHandler)
Copyright © 2008–2013 Václav Pech. All Rights Reserved.