YAACC - UPNP Client and Server
Loading...
Searching...
No Matches
de.yaacc.browser.RelaunchGuard Class Reference

Loop guard for the layout relaunch: allows at most one relaunch per time window. More...

Collaboration diagram for de.yaacc.browser.RelaunchGuard:
Collaboration graph

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.
 

Detailed Description

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.

Constructor & Destructor Documentation

◆ RelaunchGuard()

de.yaacc.browser.RelaunchGuard.RelaunchGuard ( LongSupplier clockMillis,
long windowMillis )
Parameters
clockMillismonotonic clock in milliseconds
windowMillisminimum distance between two allowed relaunches

Member Function Documentation

◆ tryRelaunch()

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.

Returns
true if the caller may relaunch, false if it must stay on its current layout

Referenced by de.yaacc.browser.BrowserLauncher.relaunchIfOtherLayout().

Here is the caller graph for this function:

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