T
- The type of Timecode
public interface TimeKeeper<T extends Timecode> extends Runnable
getTime()
method.
Subclasses must override the method to return appropriate time-based objects. Note that the time keeper is passive - it does not let anyone know when certain times occur - it merely provides times when asked.
Initially the timekeeper should not be started but should only start when
run()
is called. TimeKeepers may run continuously, so it is important
that timekeepers are run in threads.
new Thread( timeKeeper ).start()
The semantic difference between pause and stop is that pause is intended
for short term stoppages in the running of the timekeeper that will result
in the timekeeper being restarted either from the same position or from a
newly seeked position. The stop method is expected to be called when the
timekeeper is being shut down or will be required to start from the beginning
again when restarted. Some timekeepers may not support mid-stream stopping
and they should return false for the supportsPause()
method.
Similarly, timekeepers that do not support seeking should return false
for the supportsSeek()
method.
Modifier and Type | Method and Description |
---|---|
T |
getTime()
Returns the current time.
|
void |
pause()
Pause the running of the timekeeper.
|
void |
reset()
Reset the timekeeper.
|
void |
run()
Use this method to start the time keeper running.
|
void |
seek(long timestamp)
Seek to a given timestamp.
|
void |
stop()
Use this method to stop the time keeper from running.
|
boolean |
supportsPause()
Returns whether the timekeeper supports pausing.
|
boolean |
supportsSeek()
Returns whether the timekeeper supports seeking.
|
void run()
run
in interface Runnable
Runnable.run()
void pause()
void stop()
void seek(long timestamp)
timestamp
- The timestamp to seek tovoid reset()
boolean supportsPause()
boolean supportsSeek()