public class Actor<SELF extends Actor> extends Object implements Serializable, Monitorable
| Modifier and Type | Class and Description |
|---|---|
static class |
Actor.ActorReport |
| Modifier and Type | Field and Description |
|---|---|
Queue |
__cbQueue |
ConcurrentLinkedQueue<RemoteConnection> |
__connections |
Thread |
__currentDispatcher |
Queue |
__mailbox |
int |
__mbCapacity |
int |
__remoteId |
Scheduler |
__scheduler |
Actor |
__self |
boolean |
__stopped |
boolean |
__throwExAtBlock |
protected TicketMachine |
__ticketMachine |
static String |
CONT
use value as error to indicate more messages are to come (else remoting will close channel).
|
static String |
FIN
use this value to signal no more messages.
|
static String |
FINSILENT
use value to signal no more messages.
|
static ThreadLocal<Actor> |
sender |
| Constructor and Description |
|---|
Actor()
required by bytecode magic.
|
| Modifier and Type | Method and Description |
|---|---|
void |
__addDeadLetter(Actor receiver,
String methodName) |
void |
__addRemoteConnection(RemoteConnection con) |
void |
__addStopHandler(Callback<SELF> cb) |
Object |
__enqueueCall(Actor receiver,
String methodName,
Object[] args,
boolean isCB) |
Method |
__getCachedMethod(String methodName,
Actor actor) |
void |
__removeRemoteConnection(RemoteConnection con) |
void |
__stop() |
void |
$close()
closes associated remote connection(s) if present.
|
Future |
$getReport() |
Future<Monitorable[]> |
$getSubMonitorables() |
void |
$stop()
$$stop receiving events.
|
Future |
$sync()
can be used to wait for all messages having been processed
|
protected void |
checkThread()
Debug method.
|
protected void |
delayed(long millis,
Runnable toRun)
schedule an action or call delayed.
|
protected <T> Future<T> |
exec(Callable<T> callable)
execute a callable asynchronously (in a different thread) and return a future
of the result (delivered in caller thread)
WARNING: do not access local actor state (instance fields) from within the callable (=hidden parallelism).
|
SELF |
getActor() |
Actor |
getActorRef() |
int |
getCallbackSize() |
ActorProxyFactory |
getFactory() |
int |
getMailboxSize() |
int |
getQSizes() |
Scheduler |
getScheduler() |
protected boolean |
getThrowExWhenBlocked() |
protected <T> T |
inThread(Actor proxy,
T cbInterface) |
boolean |
isCallbackQPressured() |
static boolean |
isCont(Object o) |
static boolean |
isError(Object o) |
static boolean |
isFinal(Object error)
return if given error Object signals end of callback stream
|
boolean |
isMailboxPressured() |
boolean |
isProxy() |
boolean |
isRemote() |
static boolean |
isSilentFinal(Object o) |
boolean |
isStopped() |
protected Future<Future[]> |
ordered(Callable<Future>... callables)
execute given callables asynchronously, but one after another async but chained.
|
protected void |
run(Runnable toRun)
execute a callable asynchronously (in a different thread) and return a future
of the result (delivered in caller thread).
|
protected SELF |
self()
use this to call public methods using actor-dispatch instead of direct in-thread call.
|
protected void |
serialOn(Object transactionKey,
java.util.function.Consumer<Future> toRun)
enforce serial execution of asynchronous tasks.
|
protected SELF |
setThrowExWhenBlocked(boolean b)
tell the execution machinery to throw an ActorBlockedException in case the actor is blocked trying to
put a message on an overloaded actor's mailbox/queue.
|
void |
stopSafeClose()
avoids exception when closing an actor after stop has been called.
|
protected Future<Future[]> |
yield(Future... futures) |
protected <T> Future<T[]> |
yield2Result(Future<T>... futures)
same as yield, but converts the resulting Future[] to an Object[] or T[]
|
protected Future<List<Future>> |
yieldList(List<Future> futures) |
public static final String FINSILENT
public static final String CONT
public static final String FIN
public static ThreadLocal<Actor> sender
public Queue __mailbox
public int __mbCapacity
public Queue __cbQueue
public Thread __currentDispatcher
public Scheduler __scheduler
public volatile boolean __stopped
public Actor __self
public int __remoteId
public boolean __throwExAtBlock
public volatile ConcurrentLinkedQueue<RemoteConnection> __connections
protected TicketMachine __ticketMachine
public Actor()
public static boolean isFinal(Object error)
error - public static boolean isSilentFinal(Object o)
public static boolean isCont(Object o)
public static boolean isError(Object o)
protected SELF self()
public ActorProxyFactory getFactory()
public SELF getActor()
public void $stop()
public boolean isStopped()
public boolean isProxy()
protected <T> Future<T[]> yield2Result(Future<T>... futures)
futures - protected Future<Future[]> ordered(Callable<Future>... callables)
callables - protected <T> Future<T> exec(Callable<T> callable)
T - callable - protected void run(Runnable toRun)
protected <T> T inThread(Actor proxy, T cbInterface)
protected void delayed(long millis,
Runnable toRun)
public boolean isMailboxPressured()
public Scheduler getScheduler()
public boolean isCallbackQPressured()
public int getMailboxSize()
public int getQSizes()
public int getCallbackSize()
protected final void checkThread()
public Actor getActorRef()
public boolean isRemote()
public void $close()
public void stopSafeClose()
public Future $sync()
public void __addRemoteConnection(RemoteConnection con)
public void __removeRemoteConnection(RemoteConnection con)
public void __stop()
public Object __enqueueCall(Actor receiver, String methodName, Object[] args, boolean isCB)
protected void serialOn(Object transactionKey, java.util.function.Consumer<Future> toRun)
transactionKey - toRun - protected SELF setThrowExWhenBlocked(boolean b)
b - protected boolean getThrowExWhenBlocked()
public Future $getReport()
$getReport in interface Monitorablepublic Future<Monitorable[]> $getSubMonitorables()
$getSubMonitorables in interface MonitorableCopyright © 2015. All rights reserved.