Groovy Documentation

gpars.actor
Class Actor

java.lang.Object
  groovyx.gpars.actor.impl.ReceivingMessageStream
      gpars.actor.Actor

class Actor
extends ReceivingMessageStream

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.

author:
Vaclav Pech, Alex Tkachman


Nested Class Summary
class Actor.MyRemoteHandle

class Actor.RemoteActor

 
Constructor Summary
protected Actor()

protected Actor(DataFlowExpression joinLatch)

Constructor to be used by deserialization

 
Method Summary
protected RemoteHandle createRemoteHandle(SerialHandle handle, SerialContext host)

protected static void deregisterCurrentActorWithThread()

Deregisters the actor registered from the thread

DataFlowExpression getJoinLatch()

Join-point for this actor

boolean isActive()

Checks the current status of the Actor.

boolean isActorThread()

Checks whether the current thread is the actor's worker thread.

void join()

Joins the actor.

void join(MessageStream listener)

Notify listener when finished

void join(long timeout, TimeUnit unit)

Joins the actor.

void join(BaseDuration duration)

Joins the actor.

protected static void registerCurrentActorWithThread(Actor currentActor)

Registers the actor with the current thread

Actor start()

Starts the Actor.

Actor stop()

Send message to stop to the Actor.

Actor terminate()

Terminates the Actor.

static Actor threadBoundActor()

Retrieves the actor registered with the current thread

 

Constructor Detail

Actor

protected Actor()


Actor

protected Actor(DataFlowExpression joinLatch)
Constructor to be used by deserialization
param:
joinLatch The instance of DataFlowExpression to use for join operation


 
Method Detail

createRemoteHandle

@Override
protected RemoteHandle createRemoteHandle(SerialHandle handle, SerialContext host)


deregisterCurrentActorWithThread

protected static void deregisterCurrentActorWithThread()
Deregisters the actor registered from the thread


getJoinLatch

public DataFlowExpression getJoinLatch()
Join-point for this actor
return:
The DataFlowExpression instance, which is used to join this actor


isActive

public boolean isActive()
Checks the current status of the Actor.
return:
current status of the Actor.


isActorThread

public boolean isActorThread()
Checks whether the current thread is the actor's worker thread.
return:
whether the current thread is the actor's worker thread


join

public final void join()
Joins the actor. Waits for its termination.
throws:
InterruptedException when interrupted while waiting


join

public final void join(MessageStream listener)
Notify listener when finished
param:
listener listener to notify
throws:
InterruptedException if interrupted while waiting


join

public final void join(long timeout, TimeUnit unit)
Joins the actor. Waits for its termination.
param:
timeout timeout
param:
unit units of timeout
throws:
InterruptedException if interrupted while waiting


join

public final void join(BaseDuration duration)
Joins the actor. Waits for its termination.
param:
duration timeout to wait
throws:
InterruptedException if interrupted while waiting


registerCurrentActorWithThread

protected static void registerCurrentActorWithThread(Actor currentActor)
Registers the actor with the current thread
param:
currentActor The actor to register


start

public Actor start()
Starts the Actor. No messages can be sent or received before an Actor is started.
return:
same actor


stop

public Actor stop()
Send message to stop to the Actor. All messages already in queue will be processed first. No new messages will be accepted since that point. Has no effect if the Actor is not started.
return:
same actor


terminate

public Actor terminate()
Terminates the Actor. Unprocessed messages will be passed to the afterStop method, if exists. No new messages will be accepted since that point. Has no effect if the Actor is not started.
return:
same actor


threadBoundActor

public static Actor threadBoundActor()
Retrieves the actor registered with the current thread
return:
The associated actor


 

Groovy Documentation