|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.moyoman.framework.ControllerState
This class is used to prevent multiple operations from occuring on the same game simultaneously. Errors could occur if a game was being saved while the server was also making a move. This class provides methods for synchronizing access to a game. Note that the endGame method is not synchronized, since the user may wish to terminate a game without having to wait for the next move to be generated.
Field Summary | |
private static ArrayList |
games
Each element is a GameId of active games. |
private static ArrayList |
operations
Each element is a GameId which has an operation actively executing. |
private static ArrayList |
terminated
Each element is a GameId which has had endGame() called on it. |
Constructor Summary | |
(package private) |
ControllerState()
|
Method Summary | |
protected static void |
endGame(GameId id)
Remove the specified game as being active. |
protected static void |
endOperation(GameId id)
End the operation on the specified game. |
protected static void |
startGame(GameId id)
Start a new game. |
protected static void |
startOperation(GameId id)
Start an operation on the specified game if none are in progress. |
private static void |
wait(GameId id)
Wait until the current operation on the game has ended. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
private static ArrayList games
private static ArrayList operations
private static ArrayList terminated
Constructor Detail |
ControllerState()
Method Detail |
protected static void startGame(GameId id) throws InconsistentStateException
id
- The GameId object.
InconsistentStateException
- - Thrown if the id is already active.protected static void startOperation(GameId id) throws InconsistentStateException
id
- The GameId object.
InconsistentStateException
- - Thrown if the id is not an active game.protected static void endOperation(GameId id)
id
- The GameId object.protected static void endGame(GameId id)
id
- The GameId object.
InconsistentStateException
- - Thrown if the game is not active.private static void wait(GameId id)
id
- The GameId object.
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |