org.codehaus.gpars

groovyx.gpars.util
[Java] Class AsyncMessagingCore

java.lang.Object
  groovyx.gpars.util.AsyncMessagingCore
All Implemented Interfaces:
java.lang.Runnable

public abstract class AsyncMessagingCore

Authors:
Vaclav Pech Date: Aug 23, 2010


Field Summary
private static int ACTIVE

private static int PASSIVE

private int active

private static java.util.concurrent.atomic.AtomicIntegerFieldUpdater activeUpdater

private boolean fair

private MessageQueue queue

private Pool threadPool

 
Constructor Summary
protected AsyncMessagingCore(Pool threadPool)

 
Method Summary
void attachToThreadPool(Pool threadPool)

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.

protected boolean continueProcessingMessages()

Informs about a new thread being assigned to process the next message

Pool getThreadPool()

protected void handleMessage(java.lang.Object message)

boolean isFair()

Makes the agent fair.

void makeFair()

Indicates, whether there's an active thread handling a message inside the agent's body

protected void registerError(java.lang.Throwable e)

void run()

void schedule()

Removes the head of the message queue

void store(java.lang.Object message)

java.lang.Object sweepNextMessage()

protected void threadAssigned()

protected void threadUnassigned()

 
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

ACTIVE

private static final int ACTIVE


PASSIVE

private static final int PASSIVE


active

@java.lang.SuppressWarningsthreadPool.execute(this);
        }
private int active


activeUpdater

private static final java.util.concurrent.atomic.AtomicIntegerFieldUpdater activeUpdater


fair

private boolean fair


queue

private final MessageQueue queue


threadPool

private Pool threadPool


 
Constructor Detail

AsyncMessagingCore

protected AsyncMessagingCore(Pool threadPool)


 
Method Detail

attachToThreadPool

public final void attachToThreadPool(Pool threadPool)
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.


continueProcessingMessages

protected boolean continueProcessingMessages()
Informs about a new thread being assigned to process the next message
Returns:
True, if the calculation should proceed


getThreadPool

Pool getThreadPool()


handleMessage

protected void handleMessage(java.lang.Object message)


isFair

public boolean isFair()
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.


makeFair

public void makeFair()
Indicates, whether there's an active thread handling a message inside the agent's body


registerError

protected void registerError(java.lang.Throwable e)


run

@java.lang.Override} finally {
@java.lang.SuppressWarningsthreadUnassigned();
public final void run()


schedule

void schedule()
Removes the head of the message queue
Returns:
The head message, or null, if the message queue is empty


store

public void store(java.lang.Object message)


sweepNextMessage

public java.lang.Object sweepNextMessage()


threadAssigned

@java.lang.SuppressWarnings
protected void threadAssigned()


threadUnassigned

@java.lang.SuppressWarnings
protected void threadUnassigned()


 

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