|
YAACC - UPNP Client and Server
|
Loop guard for the layout relaunch: allows at most one relaunch per time window. More...

Public Member Functions | |
| RelaunchGuard (LongSupplier clockMillis, long windowMillis) | |
| synchronized boolean | tryRelaunch () |
| Asks to relaunch now. | |
Static Public Member Functions | |
| static RelaunchGuard | shared () |
| The process-wide instance used by the browser activities. | |
Static Public Attributes | |
| static final long | DEFAULT_WINDOW_MILLIS = 2000L |
| At most one relaunch per this many milliseconds. | |
Loop guard for the layout relaunch: allows at most one relaunch per time window.
Each browser activity relaunches into the other layout when the effective layout differs from its own. If that decision can ever be wrong (a stored "new" that cannot be honored, a preference flipping between two resumes), the two activities would otherwise start each other forever. When the guard denies, the caller stays on its current layout and logs.
Plain Java with an injectable clock so it can be unit tested. The clock must be monotonic (the Android side uses System#nanoTime()); a clock that still goes backwards never wedges the guard: a reading earlier than the last allowed relaunch counts as an elapsed window.
| de.yaacc.browser.RelaunchGuard.RelaunchGuard | ( | LongSupplier | clockMillis, |
| long | windowMillis ) |
| clockMillis | monotonic clock in milliseconds |
| windowMillis | minimum distance between two allowed relaunches |
| synchronized boolean de.yaacc.browser.RelaunchGuard.tryRelaunch | ( | ) |
Asks to relaunch now.
An allowed call starts a new window; a denied call does not extend it.
Referenced by de.yaacc.browser.BrowserLauncher.relaunchIfOtherLayout().
