| 1 | package com.rox.clock; | |
| 2 | ||
| 3 | /** | |
| 4 | * Something which generates ticks to {@link ClockWatcher}s | |
| 5 | */ | |
| 6 | public interface Clock { | |
| 7 | /** Add a {@link ClockWatcher} to watch for <cc>tick()</cc> events **/ | |
| 8 | void addListener(final ClockWatcher listener); | |
| 9 | /** Remove a {@link ClockWatcher} to no longer watch for <cc>tick()</cc> events **/ | |
| 10 | void removeListener(final ClockWatcher listener); | |
| 11 | /** Inform all {@link ClockWatcher}s of a <cc>tick()</cc> event **/ | |
| 12 | void tick(); | |
| 13 | /** Returns the number of {@link ClockWatcher}s on this {@link Ticker} **/ | |
| 14 | int listeners(); | |
| 15 | ||
| 16 | void run(); | |
| 17 | void stop(); | |
| 18 | ||
| 19 | /** | |
| 20 | * Call before starting {@link #run()} on another thread: until {@code run()} begins, a {@link #stop()} then | |
| 21 | * cancels that run rather than being undone by it. | |
| 22 | */ | |
| 23 | default void prepareToRun(){ | |
| 24 | } | |
| 25 | ||
| 26 | /** {@link #stop()}, then wait until {@link #run()} has returned, so nothing ticks after. */ | |
| 27 | default void stopAndWait(){ | |
| 28 |
1
1. stopAndWait : removed call to com/rox/clock/Clock::stop → KILLED |
stop(); |
| 29 | } | |
| 30 | ||
| 31 | boolean isRunning(); | |
| 32 | ||
| 33 | /** | |
| 34 | * Freeze a running {@link #run()} loop without ending it, blocking until it has genuinely stopped | |
| 35 | * ticking - so on {@code true} the caller may safely {@link #tick()} it by hand until {@link #resume()}. | |
| 36 | * | |
| 37 | * @return false if there was nothing to pause (not running, or stopped while waiting) | |
| 38 | */ | |
| 39 | default boolean pause(){ | |
| 40 |
1
1. pause : replaced boolean return with true for com/rox/clock/Clock::pause → KILLED |
return false; |
| 41 | } | |
| 42 | ||
| 43 | /** Let a {@link #pause()}d {@link #run()} loop carry on; does nothing if it isn't paused. */ | |
| 44 | default void resume(){ | |
| 45 | } | |
| 46 | } | |
Mutations | ||
| 28 |
1.1 |
|
| 40 |
1.1 |