|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object groovyx.gpars.util.AsyncMessagingCore
public abstract class AsyncMessagingCore
Field Summary | |
---|---|
private int |
active
Indicates, whether there's an active thread handling a message inside the agent's body |
private static int |
ACTIVE
|
private static java.util.concurrent.atomic.AtomicIntegerFieldUpdater<AsyncMessagingCore> |
activeUpdater
|
private boolean |
fair
Fair agents give up the thread after processing each message, non-fair agents keep a thread until their message queue is empty. |
private static int |
PASSIVE
|
private MessageQueue |
queue
Incoming messages |
private Pool |
threadPool
|
Constructor Summary | |
---|---|
protected |
AsyncMessagingCore(Pool threadPool)
|
Method Summary | |
---|---|
void |
attachToThreadPool(Pool threadPool)
Sets a new thread pool to be used by the agent |
protected boolean |
continueProcessingMessages()
Informs about a new thread being assigned to process the next message |
(package private) Pool |
getThreadPool()
|
protected abstract void |
handleMessage(java.lang.Object message)
|
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 |
makeFair()
Makes the agent fair. |
protected abstract void |
registerError(java.lang.Throwable e)
|
void |
run()
Handles a single message from the message queue |
(package private) void |
schedule()
Schedules processing of a next message, if there are some and if there isn't an active thread handling a message at the moment |
void |
store(java.lang.Object message)
Adds the message to the agent\s message queue |
java.lang.Object |
sweepNextMessage()
Removes the head of the message queue |
protected void |
threadAssigned()
Informs about the thread being removed from the task |
protected void |
threadUnassigned()
Informs about a new thread being assigned to process the next message |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private Pool threadPool
private volatile boolean fair
private final MessageQueue queue
private volatile int active
private static final java.util.concurrent.atomic.AtomicIntegerFieldUpdater<AsyncMessagingCore> activeUpdater
private static final int PASSIVE
private static final int ACTIVE
Constructor Detail |
---|
protected AsyncMessagingCore(Pool threadPool)
Method Detail |
---|
public final void attachToThreadPool(Pool threadPool)
threadPool
- The thread pool to usePool getThreadPool()
public boolean isFair()
public void makeFair()
public void store(java.lang.Object message)
message
- A value or a closurevoid schedule()
public java.lang.Object sweepNextMessage()
public final void run()
run
in interface java.lang.Runnable
protected boolean continueProcessingMessages()
protected void threadUnassigned()
protected void threadAssigned()
protected abstract void registerError(java.lang.Throwable e)
protected abstract void handleMessage(java.lang.Object message)
|
Copyright © 2008–2012 Václav Pech. All Rights Reserved. | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |