|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--coordination.Coordinator
The Coordinator class provides the basic functionality for synchronizing and coordinating different threads upon entering and exiting methods. It can be used in two different ways: 1) by instantiating regular coordinator objects that are used by aspects; or 2) by extending it (sub-classing) with coordinator aspects.
Method invocations are the smallest units for defining critical sections and pre-conditions. The use of coordinators, either regular objects or aspect instances, should always end up by invoking guardedEntry(...) in a before weave and guardedExit(...) in an after weave for all methods that need coordination. guardedEntry and guardedExit are the methods that actually manage the synchronization and coordination constraints given by their parameters and by pre-existent exclusion markers.
The synchronization of threads for the execution of critical section methods in an object is done by marking those methods as self- and/or mutually-exclusive (addSelfex, addMutex). Just by itself, addSelfex("M") does not enforce the self-exclusion of method M - enforcement is done by invoking guardedEntry before M is executed. Similarly, addMutex(new String[] {"M1", "M2"}) does not enforce the mutual exclusion between methods M1 and M2.
A guardedEntry on a method that has been marked as self-exclusive ensures that the method is executed in the invoked object by only one thread at a time. A guardedEntry on a method that has been marked has mutually- exclusive with other methods ensures that the execution of that method by a thread in the invoked object temporarily blocks the execution by other threads of the methods that are in the same mutex set.
The coordination of threads, i.e. their explicit suspension and resumption, is done through the use of pre-conditions and coordination actions that are passed as parameters to guardedEntry and guardedExit with the form of anonymous classes.
Advice Summary | ||
advice coordinatorCut() before()
| ||
advice coordinatorCut() after()
|
Crosscut Summary | |
coordinatorCut() |
Constructor Summary | |
Coordinator()
|
Method Summary | |
void |
addMutex(java.lang.String[] methNames)
Takes an array of multi-part method names and marks those methods as mutually exclusive. |
void |
addSelfex(java.lang.String methName)
Takes a multi-part method name (eg "BoundedBuffer.put") and marks that method as self-exclusive. |
void |
guardedEntry(java.lang.String methName)
This method is the guard for enforcing all synchronization and coordination constraints of a given method, and it should be called just before the method is executed. |
void |
guardedEntry(java.lang.String methName,
Condition condition)
Just like guardedEntry(String methName), but the given method is executed only when the given condition is true. |
void |
guardedEntry(java.lang.String methName,
Condition condition,
CoordinationAction action)
Just like guardedEntry(String methName), but the given method is executed only when the given condition is true; the additional coordination action that is executed before the given method is executed. |
void |
guardedEntry(java.lang.String methName,
CoordinationAction action)
Just like guardedEntry(String methName), but with an additional coordination action that is executed before the given method is executed. |
void |
guardedEntryWithTimeout(java.lang.String methName,
Condition condition,
CoordinationAction action,
long millis)
This method is similar to guardedEntry, but it takes an additional parameter - the milliseconds after which any suspension will abort with a timeout. |
void |
guardedEntryWithTimeout(java.lang.String methName,
Condition condition,
long millis)
This method is similar to guardedEntry, but it takes an additional parameter - the milliseconds after which any suspension will abort with a timeout. |
void |
guardedEntryWithTimeout(java.lang.String methName,
CoordinationAction action,
long millis)
This method is similar to guardedEntry, but it takes an additional parameter - the milliseconds after which any suspension will abort with a timeout. |
void |
guardedEntryWithTimeout(java.lang.String methName,
long millis)
This method is similar to guardedEntry, but it takes an additional parameter - the milliseconds after which any suspension will abort with a timeout. |
void |
guardedExit(java.lang.String methName)
This method provides the means for updating all synchronization and coordination state after the execution of a given method, and it should be called after the method is executed. |
void |
guardedExit(java.lang.String methName,
CoordinationAction action)
Just like guardedExit(String methName) but with an additional coordination action that is executed. |
void |
removeMutex(java.lang.String[] methNames)
Takes an array of multi-part method names that correspond to an existing mutex set and remove the mutual exclusion constraint. |
void |
removeSelfex(java.lang.String methName)
Takes a multi-part method name (e.g. |
Methods inherited from class java.lang.Object |
|
Advice Detail |
before()
affects: spacewar.Game, spacewar.Registry |
after()
affects: spacewar.Game, spacewar.Registry |
Crosscut Detail |
Constructor Detail |
public Coordinator()
Method Detail |
public void addSelfex(java.lang.String methName)
public void removeSelfex(java.lang.String methName)
public void addMutex(java.lang.String[] methNames)
public void removeMutex(java.lang.String[] methNames)
public void guardedEntry(java.lang.String methName)
public void guardedEntry(java.lang.String methName, Condition condition)
public void guardedEntry(java.lang.String methName, CoordinationAction action)
public void guardedEntry(java.lang.String methName, Condition condition, CoordinationAction action)
public void guardedEntryWithTimeout(java.lang.String methName, long millis) throws TimeoutException
public void guardedEntryWithTimeout(java.lang.String methName, Condition condition, long millis) throws TimeoutException
public void guardedEntryWithTimeout(java.lang.String methName, CoordinationAction action, long millis) throws TimeoutException
public void guardedEntryWithTimeout(java.lang.String methName, Condition condition, CoordinationAction action, long millis) throws TimeoutException
public void guardedExit(java.lang.String methName)
public void guardedExit(java.lang.String methName, CoordinationAction action)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |