Groovy Documentation

gpars.group
[Groovy] Class PGroup

java.lang.Object
  gpars.group.PGroup

abstract class PGroup

Provides a common super class of pooled actor groups.

Authors:
Vaclav Pech, Alex Tkachman Date: May 8, 2009


Constructor Summary
protected PGroup(Pool threadPool)

Creates a group for actors, agents, tasks and operators.

 
Method Summary
AbstractPooledActor actor(Runnable handler)

Creates a new instance of PooledActor, using the passed-in runnable/closure as the body of the actor's act() method.

Agent agent(def state)

Creates an agent instance initialized with the given state

Agent agent(def state, groovy.lang.Closure copy)

Creates an agent instance initialized with the given state

Agent fairAgent(def state)

Creates an agent instance initialized with the given state, which will cooperate in thread sharing with other Agent instances in a fair manner.

Agent fairAgent(def state, groovy.lang.Closure copy)

Creates an agent instance initialized with the given state, which will cooperate in thread sharing with other Agent instances in a fair manner.

Pool getThreadPool()

AbstractPooledActor messageHandler(groovy.lang.Closure code)

Creates an instance of DynamicDispatchActor.

DataFlowOperator operator(Map channels, groovy.lang.Closure code)

Creates an operator using the current actor group

AbstractPooledActor reactor(groovy.lang.Closure code)

Creates a reactor around the supplied code.

void task(groovy.lang.Closure code)

Creates a new task assigned to a thread from the current actor group.

 
Methods inherited from class Object
wait, wait, wait, equals, toString, hashCode, getClass, notify, notifyAll
 

Constructor Detail

PGroup

protected PGroup(Pool threadPool)
Creates a group for actors, agents, tasks and operators. The actors will share a common daemon thread pool.


 
Method Detail

actor

final AbstractPooledActor actor(Runnable handler)
Creates a new instance of PooledActor, using the passed-in runnable/closure as the body of the actor's act() method. The created actor will belong to the pooled actor group.
Parameters:
handler - The body of the newly created actor's act method.
Returns:
A newly created instance of the AbstractPooledActor class


agent

final Agent agent(def state)
Creates an agent instance initialized with the given state
Parameters:
state - The initial internal state of the new Agent instance
Returns:
The created instance


agent

final Agent agent(def state, groovy.lang.Closure copy)
Creates an agent instance initialized with the given state
Parameters:
state - The initial internal state of the new Agent instance
copy - A closure to use to create a copy of the internal state when sending the internal state out
Returns:
The created instance


fairAgent

final Agent fairAgent(def state)
Creates an agent instance initialized with the given state, which will cooperate in thread sharing with other Agent instances in a fair manner.
Parameters:
state - The initial internal state of the new Agent instance
Returns:
The created instance


fairAgent

final Agent fairAgent(def state, groovy.lang.Closure copy)
Creates an agent instance initialized with the given state, which will cooperate in thread sharing with other Agent instances in a fair manner.
Parameters:
copy - A closure to use to create a copy of the internal state when sending the internal state out
state - The initial internal state of the new Agent instance
Returns:
The created instance


getThreadPool

Pool getThreadPool()


messageHandler

final AbstractPooledActor messageHandler(groovy.lang.Closure code)
Creates an instance of DynamicDispatchActor.
Parameters:
code - The closure specifying individual message handlers.


operator

DataFlowOperator operator(Map channels, groovy.lang.Closure code)
Creates an operator using the current actor group
Parameters:
channels - A map specifying "inputs" and "outputs" - dataflow channels (instances of the DataFlowStream or DataFlowVariable classes) to use for inputs and outputs
code - The operator's body to run each time all inputs have a value to read


reactor

final AbstractPooledActor reactor(groovy.lang.Closure code)
Creates a reactor around the supplied code. 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.
Parameters:
The - code to invoke for each received message
Returns:
A new instance of ReactiveEventBasedThread


task

void task(groovy.lang.Closure code)
Creates a new task assigned to a thread from the current actor group. Tasks are a lightweight version of dataflow operators, which do not define their communication channels explicitly, but can only exchange data using explicit DataFlowVariables and Streams.
Parameters:
code - The task body to run


 

Groovy Documentation