uk.ac.man.cs.rainbow.simulator
Class ReclaimableSavedState
java.lang.Object
|
+--uk.ac.man.cs.rainbow.simulator.ReclaimableSavedState
- All Implemented Interfaces:
- SavedState, Serializable
- public class ReclaimableSavedState
- extends Object
- implements SavedState
A saved state that can save space by writing itself out to disk.
- See Also:
- Serialized Form
Method Summary |
void |
dispose()
Relinquish the resources held in this saved state. |
protected void |
finalize()
|
SavedState |
getState()
Get the real saved state. |
int |
hashCode()
|
protected SavedState |
load(File file)
Load a state from disk, and cache it in a local reclaimable reference. |
protected void |
save(File file,
SavedState state)
Save a state to disk, and cache it in a local reclaimable reference. |
void |
weaken()
Attempt to move the state from memory to disk. |
ReclaimableSavedState
public ReclaimableSavedState(SavedState stateToCache)
load
protected SavedState load(File file)
throws IOException,
ClassNotFoundException
- Load a state from disk, and cache it in a local reclaimable reference.
save
protected void save(File file,
SavedState state)
throws IOException
- Save a state to disk, and cache it in a local reclaimable reference.
getState
public SavedState getState()
- Get the real saved state. Uses the internal copy if it exists,
and attempts to reload from disk otherwise.
- Specified by:
getState
in interface SavedState
- Throws:
ReclaimableSavedState.StateReloadException
- If a state reload proves impossible.- See Also:
load(File)
weaken
public void weaken()
throws IOException
- Attempt to move the state from memory to disk. After moving
to disk, the state is still cached in memory until the VM
would run out of memory.
- See Also:
SoftReference
,
save(File,SavedState)
dispose
public void dispose()
- Relinquish the resources held in this saved state. In
particular, if the state was written out to disk, then that
disk state is deleted.
- Specified by:
dispose
in interface SavedState
finalize
protected void finalize()
throws Throwable
- Overrides:
finalize
in class Object
hashCode
public int hashCode()
- Overrides:
hashCode
in class Object