|
org.codehaus.gpars | |||||||
FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object groovyx.gpars.serial.WithSerialId groovyx.gpars.actor.impl.MessageStream groovyx.gpars.actor.Actor
public abstract class Actor extends MessageStream
Actors are active objects, which borrow a thread from a thread pool. The Actor interface provides means to send messages to the actor, start and stop the background thread as well as check its status.
Nested Class Summary | |
---|---|
static class |
Actor.MyRemoteHandle
|
static class |
Actor.RemoteActor
|
Field Summary | |
---|---|
protected static java.lang.String |
ACTOR_HAS_ALREADY_BEEN_STARTED
|
private static java.lang.String |
AFTER_START
|
static java.lang.String |
CANNOT_SEND_REPLIES_NO_SENDER_HAS_BEEN_REGISTERED
|
private static java.lang.Object[] |
EMPTY_ARGUMENTS
|
private static java.lang.String |
ON_DELIVERY_ERROR
|
private static java.lang.String |
RESPONDS_TO
|
protected static ActorMessage |
START_MESSAGE
|
protected static ActorMessage |
STOP_MESSAGE
|
protected static ActorMessage |
TERMINATE_MESSAGE
|
static java.lang.String |
TIMEOUT
|
protected static ActorMessage |
TIMEOUT_MESSAGE
|
private static java.lang.ThreadLocal |
currentActorPerThread
|
protected java.lang.Thread |
currentThread
|
private DataflowExpression |
joinLatch
|
private groovy.lang.Closure |
onStop
|
protected PGroup |
parallelGroup
|
private static long |
serialVersionUID
|
protected static GeneralTimer |
timer
|
Fields inherited from class MessageStream | |
---|---|
serialVersionUID |
Fields inherited from class WithSerialId | |
---|---|
serialHandle, serialVersionUID |
Constructor Summary | |
protected Actor()
|
|
protected Actor(DataflowExpression joinLatch)
Retrieves the group to which the actor belongs |
|
protected Actor(DataflowExpression joinLatch, PGroup parallelGroup)
|
Method Summary | |
---|---|
private boolean
|
callDynamic(java.lang.String method, java.lang.Object[] args)
|
protected ActorMessage
|
createActorMessage(java.lang.Object message)
|
protected RemoteHandle
|
createRemoteHandle(SerialHandle handle, SerialContext host)
|
protected static void
|
deregisterCurrentActorWithThread()
|
DataflowExpression
|
getJoinLatch()
|
PGroup
|
getParallelGroup()
|
protected void
|
handleException(java.lang.Throwable exception)
|
protected void
|
handleInterrupt(java.lang.InterruptedException exception)
|
protected void
|
handleStart()
|
protected void
|
handleTermination()
Set on stop handler for this actor |
protected void
|
handleTimeout()
|
protected boolean
|
hasBeenStopped()
|
boolean
|
isActive()
|
boolean
|
isActorThread()
Checks whether the current thread is the actor's current thread. |
void
|
join()
|
void
|
join(MessageStream listener)
|
void
|
join(long timeout, java.util.concurrent.TimeUnit unit)
Joins the actor. |
void
|
join(groovy.time.BaseDuration duration)
Join-point for this actor |
void
|
onStop(groovy.lang.Closure onStop)
|
protected static void
|
registerCurrentActorWithThread(Actor currentActor)
|
MessageStream
|
sendAndContinue(java.lang.Object message, groovy.lang.Closure closure)
Sends a message and returns a promise for the reply. |
Promise
|
sendAndPromise(java.lang.Object message)
|
void
|
setParallelGroup(PGroup group)
Sends a message and execute continuation when reply became available. |
Actor
|
silentStart()
Starts the Actor and sends it the START_MESSAGE to run any afterStart handlers. |
Actor
|
start()
|
Actor
|
stop()
|
protected ActorMessage
|
sweepNextMessage()
Clears the message queue returning all the messages it held. |
java.util.List
|
sweepQueue()
|
Actor
|
terminate()
Joins the actor. |
static Actor
|
threadBoundActor()
|
Methods inherited from class MessageStream | |
---|---|
call, getRemoteClass, leftShift, reInterrupt, send, send, send, sendAndWait, sendAndWait, sendAndWait |
Methods inherited from class WithSerialId | |
---|---|
createRemoteHandle, getOrCreateSerialHandle, getRemoteClass, writeReplace |
Field Detail |
---|
protected static final java.lang.String ACTOR_HAS_ALREADY_BEEN_STARTED
private static final java.lang.String AFTER_START
public static final java.lang.String CANNOT_SEND_REPLIES_NO_SENDER_HAS_BEEN_REGISTERED
private static final java.lang.Object[] EMPTY_ARGUMENTS
private static final java.lang.String ON_DELIVERY_ERROR
private static final java.lang.String RESPONDS_TO
protected static final ActorMessage START_MESSAGE
protected static final ActorMessage STOP_MESSAGE
protected static final ActorMessage TERMINATE_MESSAGE
@java.lang.SuppressWarnings} public static final java.lang.String TIMEOUT
protected static final ActorMessage TIMEOUT_MESSAGE
private static final java.lang.ThreadLocal currentActorPerThread
protected java.lang.Thread currentThread
private final DataflowExpression joinLatch
private groovy.lang.Closure onStop
protected PGroup parallelGroup
private static final long serialVersionUID
protected static final GeneralTimer timer
Constructor Detail |
---|
protected Actor()
protected Actor(DataflowExpression joinLatch)
protected Actor(DataflowExpression joinLatch, PGroup parallelGroup)
Method Detail |
---|
private boolean callDynamic(java.lang.String method, java.lang.Object[] args)
protected final ActorMessage createActorMessage(java.lang.Object message)
@java.lang.OverrideonStop.call(queue); protected RemoteHandle createRemoteHandle(SerialHandle handle, SerialContext host)
protected static void deregisterCurrentActorWithThread()
public DataflowExpression getJoinLatch()
public final PGroup getParallelGroup()
@java.lang.SuppressWarnings} protected void handleException(java.lang.Throwable exception)
@java.lang.SuppressWarningsfinal MetaClass metaClass = InvokerHelper.getMetaClass(this); protected void handleInterrupt(java.lang.InterruptedException exception)
@java.lang.SuppressWarnings/** protected void handleStart()
protected void handleTermination()
onStop
- The code to invoke when stopping
protected void handleTimeout()
protected boolean hasBeenStopped()
public boolean isActive()
public final boolean isActorThread()
public final void join()
public final void join(MessageStream listener)
public final void join(long timeout, java.util.concurrent.TimeUnit unit)
duration
- timeout to wait
public final void join(groovy.time.BaseDuration duration)
public final void onStop(groovy.lang.Closure onStop)
protected static void registerCurrentActorWithThread(Actor currentActor)
@java.lang.SuppressWarningspublic finalPromise
message
- message to send
@java.lang.SuppressWarnings* No messages can be sent or received before an Actor is started. public final Promise sendAndPromise(java.lang.Object message)
public void setParallelGroup(PGroup group)
message
- message to sendclosure
- closure to execute when reply became available
public Actor silentStart()
public Actor start()
public Actor stop()
protected ActorMessage sweepNextMessage()
@java.lang.SuppressWarningsmessages.add(message); final java.util.List sweepQueue()
public Actor terminate()
public static Actor threadBoundActor()
Copyright © 2008–2013 Václav Pech. All Rights Reserved.