org.codehaus.gpars

groovyx.gpars.agent
[Java] Class AgentCore

java.lang.Object
  groovyx.gpars.agent.AgentCore

@SuppressWarnings({"UnqualifiedStaticUsage"})
public abstract class AgentCore
extends java.lang.Object

Authors:
Vaclav Pech Date: 13.4.2010


Field Summary
private AsyncMessagingCore core

private java.util.List errors

Holds agent errors

 
Constructor Summary
protected AgentCore()

 
Method Summary
void attachToThreadPool(Pool threadPool)

Sets a new thread pool to be used by the agent

void call(java.lang.Object message)

Adds the message to the agent\s message queue

java.util.List getErrors()

Retrieves a list of exception thrown within the agent's body.

void handleMessage(java.lang.Object message)

Dynamically dispatches the method call

boolean hasErrors()

Indicates whether there have been exception thrown within the agent's body.

boolean isFair()

Retrieves the agent's fairness flag Fair agents give up the thread after processing each message, non-fair agents keep a thread until their message queue is empty.

void leftShift(java.lang.Object message)

Adds the message to the agent\s message queue

void makeFair()

Makes the agent fair.

void registerError(java.lang.Throwable e)

Adds the exception to the list of thrown exceptions

void send(java.lang.Object message)

Adds the message to the agent\s message queue

void setPGroup(PGroup pGroup)

Sets an actor group to use for task scheduling

 
Methods inherited from class java.lang.Object
java.lang.Object#wait(long), java.lang.Object#wait(), java.lang.Object#wait(long, int), 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

core

private final AsyncMessagingCore core


errors

private java.util.List errors
Holds agent errors


 
Constructor Detail

AgentCore

protected AgentCore()


 
Method Detail

attachToThreadPool

public final void attachToThreadPool(Pool threadPool)
Sets a new thread pool to be used by the agent
Parameters:
threadPool - The thread pool to use


call

@SuppressWarnings({"UnusedDeclaration"})
public final void call(java.lang.Object message)
Adds the message to the agent\s message queue
Parameters:
message - A value or a closure


getErrors

@SuppressWarnings({"SynchronizedMethod", "ReturnOfCollectionOrArrayField"})
public java.util.List getErrors()
Retrieves a list of exception thrown within the agent's body. Clears the exception history
Returns:
A detached collection of exception that have occurred in the agent's body


handleMessage

void handleMessage(java.lang.Object message)
Dynamically dispatches the method call
Parameters:
message - A value or a closure


hasErrors

@SuppressWarnings({"SynchronizedMethod"})
public boolean hasErrors()
Indicates whether there have been exception thrown within the agent's body.
Returns:
True, if any exceptions have occurred in the agent's body


isFair

public boolean isFair()
Retrieves the agent's fairness flag Fair agents give up the thread after processing each message, non-fair agents keep a thread until their message queue is empty. Non-fair agents tend to perform better than fair ones.
Returns:
True for fair agents, false for non-fair ones. Agents are non-fair by default.


leftShift

@SuppressWarnings({"UnusedDeclaration"})
public final void leftShift(java.lang.Object message)
Adds the message to the agent\s message queue
Parameters:
message - A value or a closure


makeFair

public void makeFair()
Makes the agent fair. Agents are non-fair by default. Fair agents give up the thread after processing each message, non-fair agents keep a thread until their message queue is empty. Non-fair agents tend to perform better than fair ones.


registerError

@SuppressWarnings({"MethodOnlyUsedFromInnerClass", "SynchronizedMethod"})
void registerError(java.lang.Throwable e)
Adds the exception to the list of thrown exceptions
Parameters:
e - The exception to store


send

public final void send(java.lang.Object message)
Adds the message to the agent\s message queue
Parameters:
message - A value or a closure


setPGroup

public void setPGroup(PGroup pGroup)
Sets an actor group to use for task scheduling
Parameters:
pGroup - The pGroup to use


 

Copyright © 2008–2010 Václav Pech. All Rights Reserved.