au.com.solidsoftware.multimahjong.shared
Class StartGameSynch

java.lang.Object
  |
  +--au.com.solidsoftware.multimahjong.shared.StartGameSynch

public class StartGameSynch
extends java.lang.Object

StartGameSynch is just a class that provides for a synchronization object when creating a game. Because the players who have joined need to wait for the players who createed the game to begin, they need to sit in some sort of wait loop. This wait loop gets notified when the creator finally decides to begin the game, and this class is the mutual exclusive lock. It could not be implemented in RemoteReferee because it extends Referee which uses its own wait/notify pairs.

Author:
Michael Hart
See Also:
RemoteReferee, Referee

Field Summary
private  boolean gameHasStarted
          True when the game has started
private  Referee referee
          Reference to the Referee that runs the game
 
Constructor Summary
StartGameSynch(Referee referee)
          Initialises the local referee variable and sets gameHasStarted to false.
 
Method Summary
 Referee startGame()
          Sets gameHasStarted to true, notifies everyone waiting and then returns a reference to the Referee.
 Referee waitForStart()
          Waits for gameHasStarted to be true and then returns a reference to the Referee.
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 

Field Detail

gameHasStarted

private boolean gameHasStarted
True when the game has started

referee

private Referee referee
Reference to the Referee that runs the game
Constructor Detail

StartGameSynch

public StartGameSynch(Referee referee)
Initialises the local referee variable and sets gameHasStarted to false.
Parameters:
referee - the Referee that runs the game
See Also:
Referee
Method Detail

startGame

public Referee startGame()
                  throws java.rmi.RemoteException
Sets gameHasStarted to true, notifies everyone waiting and then returns a reference to the Referee.
See Also:
Referee

waitForStart

public Referee waitForStart()
Waits for gameHasStarted to be true and then returns a reference to the Referee.
See Also:
Referee