YAACC - UPNP Client and Server
Loading...
Searching...
No Matches
de.yaacc.share.ReadinessWait Class Reference

Waits, bounded, until something becomes true (for example the local HTTP server accepts connections after a cold start). More...

Collaboration diagram for de.yaacc.share.ReadinessWait:
Collaboration graph

Classes

interface  Sleeper
 How the waiting thread sleeps. More...
 

Static Public Member Functions

static boolean await (BooleanSupplier ready, long maxMillis, long pollMillis)
 Same with the system clock and Thread#sleep.
 
static boolean await (BooleanSupplier ready, long maxMillis, long pollMillis, LongSupplier clock, Sleeper sleeper)
 Checks ready, then every pollMillis until it is true or maxMillis have passed (one last check at the end).
 

Detailed Description

Waits, bounded, until something becomes true (for example the local HTTP server accepts connections after a cold start).

Plain Java with an injectable clock and sleeper. Blocks the calling thread: never call it on the main thread.

Member Function Documentation

◆ await()

static boolean de.yaacc.share.ReadinessWait.await ( BooleanSupplier ready,
long maxMillis,
long pollMillis,
LongSupplier clock,
Sleeper sleeper )
static

Checks ready, then every pollMillis until it is true or maxMillis have passed (one last check at the end).

A check that throws counts as not ready. An interrupt ends the wait with false and keeps the thread's interrupt flag.

Returns
true if ready became true in time

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