| 
org.codehaus.gpars | |||||||
| FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||
java.lang.Objectgroovyx.gpars.util.AsyncMessagingCore
public abstract class AsyncMessagingCore
| Field Summary | |
|---|---|
        private static int | 
        
            ACTIVE
             | 
        
        private static int | 
        
            PASSIVE
             | 
        
        private int | 
        
            active
            Indicates, whether there's an active thread handling a message inside the agent's body  | 
        
        private static java.util.concurrent.atomic.AtomicIntegerFieldUpdater | 
        
            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 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  | 
        
            Pool
         | 
        
            getThreadPool()
             | 
        
            protected 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 void
         | 
        
            registerError(java.lang.Throwable e)
             | 
        
            void
         | 
        
            run()
            Handles a single message from the message queue  | 
        
            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 | |
|---|---|
| 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 | 
|---|
private static final int ACTIVE
private static final int PASSIVE
@SuppressWarnings({"FieldMayBeFinal", "unused"}) //  TODO:  Eclipse requires this to be tagged as unused.
private int active
        
private static final java.util.concurrent.atomic.AtomicIntegerFieldUpdater activeUpdater
private boolean fair
private final MessageQueue queue
private Pool threadPool
| Constructor Detail | 
|---|
protected AsyncMessagingCore(Pool threadPool)
| Method Detail | 
|---|
public final void attachToThreadPool(Pool threadPool)
threadPool -  The thread pool to use
protected boolean continueProcessingMessages()
Pool getThreadPool()
protected void handleMessage(java.lang.Object message)
public boolean isFair()
public void makeFair()
protected void registerError(java.lang.Throwable e)
@Override
@SuppressWarnings({"CatchGenericClass", "ThrowCaughtLocally", "OverlyBroadCatchBlock"})
public final void run()
        
void schedule()
public void store(java.lang.Object message)
message -  A value or a closure
public java.lang.Object sweepNextMessage()
@SuppressWarnings({"NoopMethodInAbstractClass"})
protected void threadAssigned()
        
@SuppressWarnings({"NoopMethodInAbstractClass"})
protected void threadUnassigned()
        
Copyright © 2008–2012 Václav Pech. All Rights Reserved.