Rabbit Escape  2017-01-14_18:33:47_+0000__(tag:_v0.10.1)
Classes | Public Member Functions | Public Attributes | Private Member Functions | Private Attributes | List of all members
rabbitescape.ui.android.WorldSaver Class Reference
Collaboration diagram for rabbitescape.ui.android.WorldSaver:
Collaboration graph
[legend]

Classes

class  Signal
 

Public Member Functions

 WorldSaver (World world, AndroidGameLaunch gameLaunch)
 
void check ()
 
void waitUnlessSaveSignal (long wait_time)
 
String[] waitUntilSaved ()
 

Public Attributes

String[] savedWorld = null
 

Private Member Functions

String[] actuallySaveWorld ()
 

Private Attributes

final World world
 
final AndroidGameLaunch gameLaunch
 
final Signal requestSave = new Signal()
 
final Signal saved = new Signal()
 
boolean saveWorld = false
 

Detailed Description

Hairy synchronization of the game loop, and the UI/system thread to ensure the world saves correctly.

Only the game loop can stop what it is doing to save the world, but it is the UI/system thread that asks for the saved world.

Constructor & Destructor Documentation

rabbitescape.ui.android.WorldSaver.WorldSaver ( World  world,
AndroidGameLaunch  gameLaunch 
)

Member Function Documentation

String [] rabbitescape.ui.android.WorldSaver.actuallySaveWorld ( )
private
void rabbitescape.ui.android.WorldSaver.check ( )

Game loop thread: checks whether we've been asked to save the world, and if so, blocks here while it does it.

void rabbitescape.ui.android.WorldSaver.waitUnlessSaveSignal ( long  wait_time)

Game loop thread: pauses the time supplied, but will be interrupted if the UI/system thread wakes us up by calling calls waitUntilSaved().

String [] rabbitescape.ui.android.WorldSaver.waitUntilSaved ( )

UI/system thread: requests a world save, wakes up the game loop if it is sleeping, then blocks until the game loop has saved the world, which it does by calling check().

Returns
the saved model

Member Data Documentation

final AndroidGameLaunch rabbitescape.ui.android.WorldSaver.gameLaunch
private
final Signal rabbitescape.ui.android.WorldSaver.requestSave = new Signal()
private
final Signal rabbitescape.ui.android.WorldSaver.saved = new Signal()
private
String [] rabbitescape.ui.android.WorldSaver.savedWorld = null
boolean rabbitescape.ui.android.WorldSaver.saveWorld = false
private
final World rabbitescape.ui.android.WorldSaver.world
private

The documentation for this class was generated from the following file: