Time.Sleep
eff SleepSourceAn effect used to sleep the current thread.
Operations
def sleep(d: Duration): Unit \ Sleep
SourceSleeps the current thread for the given duration d.
Definitions
def handle(f: a -> b \ ef): a -> b \ (ef - Sleep) + IO
SourceHandles the Sleep effect of the given function f.
In other words, re-interprets the Sleep effect using the IO effect.
@DefaultHandler def runWithIO(f: Unit -> a \ ef): a \ (ef - Sleep) + IO
SourceRuns the Sleep effect of the given function f.
In other words, re-interprets the Sleep effect using the IO effect.
def withCollect(f: Unit -> a \ ef): (a, List[Duration]) \ ef - Sleep
SourceRuns the given function f collecting all sleep durations into a list.
Returns a pair of the result and the list of durations in call order.
def withConstant(duration: Duration, f: Unit -> a \ ef): a \ (ef - Sleep) + Sleep
SourceMiddleware that intercepts the Sleep effect, replacing each sleep duration
with the given constant duration, ignoring the original duration.
def withJitter(factor: Float64, f: Unit -> a \ ef): a \ (ef - Sleep) + Sleep + Random
SourceMiddleware that intercepts the Sleep effect, adding random jitter to each
sleep duration. The factor controls the maximum jitter fraction, e.g. 0.2
means each sleep duration is randomly adjusted by up to ±20%.
def withLogging(f: Unit -> a \ ef): a \ (ef - Sleep) + Sleep + Logger
SourceMiddleware that intercepts the Sleep effect, logging each sleep duration
via the Logger effect and re-raising the Sleep effect.
def withMaxSleep(cap: Duration, f: Unit -> a \ ef): a \ (ef - Sleep) + Sleep
SourceMiddleware that intercepts the Sleep effect, capping each sleep duration
to the given cap.
def withMaxTotalSleep(budget: Duration, f: Unit -> a \ ef): a \ (ef - Sleep) + Sleep
SourceMiddleware that intercepts the Sleep effect, capping the total cumulative
sleep duration to the given budget. Once the budget is exhausted, all
further sleeps become no-ops.
def withMinSleep(floor: Duration, f: Unit -> a \ ef): a \ (ef - Sleep) + Sleep
SourceMiddleware that intercepts the Sleep effect, ensuring each sleep duration
is at least the given floor.
def withNoOp(f: Unit -> a \ ef): a \ ef - Sleep
SourceRuns the given function f ignoring all sleeps (no-op).
def withScale(factor: Float64, f: Unit -> a \ ef): a \ (ef - Sleep) + Sleep
SourceMiddleware that intercepts the Sleep effect, scaling each sleep duration
by the given factor.