public class Actor
extends java.lang.Thread
This class implements, in an object-oriented way, the message passing
thread communication mechanism.
Important Note: external synchronization is not yet implemented.
This class follows DbC(tm) methodology
(Wikipedia).
Where possible, contracts are implement with native's Java
assert.
Modifier and Type | Class and Description |
---|---|
protected class |
Actor.Routine
ADT of actor's routines closure.
|
Modifier and Type | Field and Description |
---|---|
protected java.util.Queue<Actor.Routine> |
pending
routine calls pending for execution
|
protected java.util.Queue<Actor.Routine> |
pendingCSync
routine calls pending due to conditional synchronization
|
protected boolean |
runUniqueInvocation |
protected boolean |
terminated |
Constructor and Description |
---|
Actor()
Constructs a new Actor (note that its attached thread is not started here).
|
Modifier and Type | Method and Description |
---|---|
protected void |
futureDone(pt.ua.concurrent.Future future)
Indicates that the routine attached to future is done.
|
protected void |
inPendingRoutine(Actor.Routine r)
Queue's a routine for execution by the actor.
|
void |
run()
The actor's message handling routine.
|
protected boolean |
runUniqueInvocation()
Has run not executed yet?
(This method is only for internal usage to ensure that run method is
executed only by the thread's start method.)
|
void |
terminate()
Terminate te execution of actor.
|
boolean |
terminated()
Is the actor terminated?
|
activeCount, checkAccess, clone, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yield
protected final java.util.Queue<Actor.Routine> pending
protected final java.util.Queue<Actor.Routine> pendingCSync
protected boolean terminated
protected boolean runUniqueInvocation
public Actor()
protected void futureDone(pt.ua.concurrent.Future future)
requires: future != null
requires: isAlive()
future
- the future objectprotected void inPendingRoutine(Actor.Routine r)
requires: r != null
r
- the routine objectpublic void terminate()
requires: isAlive()
public boolean terminated()
boolean
true if the actor has finished, false otherwiseprotected boolean runUniqueInvocation()
boolean
true if run has not yet started execution, false otherwisepublic void run()
run
in interface java.lang.Runnable
run
in class java.lang.Thread