public class Agent<T> extends AgentBase<T>
currentThread
Constructor and Description |
---|
Agent()
Creates a new Agent with the internal state set to null
|
Agent(T data)
Creates a new Agent around the supplied modifiable object
|
Agent(T data,
groovy.lang.Closure copy)
Creates a new Agent around the supplied modifiable object
|
Modifier and Type | Method and Description |
---|---|
static <T> Agent<T> |
agent(T state)
Creates an agent instance initialized with the given state.
|
static <T> Agent<T> |
agent(T state,
groovy.lang.Closure copy)
Creates an agent instance initialized with the given state.
|
static <T> Agent<T> |
fairAgent(T state)
Creates an agent instance initialized with the given state, which will cooperate in thread sharing with other Agent instances
in a fair manner.
|
static <T> Agent<T> |
fairAgent(T 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.
|
void |
handleMessage(java.lang.Object message)
Dynamically dispatches the method call
|
addListener, addValidator, await, getInstantVal, getVal, onMessage, onMessage, onMessage, sendAndWait, updateValue, valAsync
public Agent()
public Agent(T data)
data
- The object to use for storing the internal state of the variablepublic Agent(T data, groovy.lang.Closure copy)
data
- The object to use for storing the internal state of the variablecopy
- A closure to use to create a copy of the internal state when sending the internal state outpublic void handleMessage(java.lang.Object message)
handleMessage
in class AgentCore
message
- A value or a closurepublic static <T> Agent<T> agent(T state)
state
- The initial internal state of the new Agent instancepublic static <T> Agent<T> agent(T state, groovy.lang.Closure copy)
state
- The initial internal state of the new Agent instancecopy
- A closure to use to create a copy of the internal state when sending the internal state outpublic static <T> Agent<T> fairAgent(T state)
state
- The initial internal state of the new Agent instancepublic static <T> Agent<T> fairAgent(T state, groovy.lang.Closure copy)
state
- The initial internal state of the new Agent instancecopy
- A closure to use to create a copy of the internal state when sending the internal state out