|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectgames.strategy.engine.delegate.DelegateExecutionManager
public class DelegateExecutionManager
Manages when delegates are allowed to execute.
When saving a game, we want to ensure that no delegate is executing, otherwise the delegate could modify the state of the game while the game is being saved, resulting in an invalid save game.
This class effectivly keeps a count of how many threads are executing in the delegates, and provides a way of blocking further threads from starting execution in a delegate.
| Constructor Summary | |
|---|---|
DelegateExecutionManager()
|
|
| Method Summary | |
|---|---|
boolean |
blockDelegateExecution(int timeToWaitMS)
When this method returns true, threads will not be able to enter delegates until a call to resumeDelegateExecution is made. |
java.lang.Object |
createInboundImplementation(java.lang.Object implementor,
java.lang.Class<?>[] interfaces)
Use to create an object that begins delegate execution. |
java.lang.Object |
createOutboundImplementation(java.lang.Object implementor,
java.lang.Class<?>[] interfaces)
Used to create an object the exits delegate execution. |
void |
enterDelegateExecution()
|
void |
leaveDelegateExecution()
|
void |
resumeDelegateExecution()
Allow delegate execution to resume. |
void |
setGameOver()
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public DelegateExecutionManager()
| Method Detail |
|---|
public void setGameOver()
public boolean blockDelegateExecution(int timeToWaitMS)
throws java.lang.InterruptedException
When delegateExecution is blocked, it also blocks subsequent cals to blockDelegateExecution(...)
If timeToWaitMS is > 0, we will give up trying to block delegate execution after timeTiWaitMS has elapsed.
timeToWait -
java.lang.InterruptedExceptionpublic void resumeDelegateExecution()
public java.lang.Object createOutboundImplementation(java.lang.Object implementor,
java.lang.Class<?>[] interfaces)
Objects on this method will decrement the thread lock count when called, and will increment it again when execution is finished.
public java.lang.Object createInboundImplementation(java.lang.Object implementor,
java.lang.Class<?>[] interfaces)
Objects on this method will increment the thread lock count when called, and will decrement it again when execution is finished.
public void leaveDelegateExecution()
public void enterDelegateExecution()
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||