Sleep can be used to sleep for some duration once.
The underlying timer has millisecond resolution.
- ofNative :: (
- native : Internal.UV.Timer
- )
Instances For
Set up a Sleep that waits for duration milliseconds.
This function only initializes but does not yet start the timer.
Equations
- Std.Async.Sleep.mk duration = do let native ← liftM (Std.Internal.UV.Timer.mk (Std.Async.timeoutOf✝ duration) false) pure { native := native }
Instances For
If:
sis not yet running start it and return anAsynccomputation that will complete once the previously configureddurationhas elapsed.sis already running, or finished after completing, return the sameAsynccomputation as the last call towait. A select that checkssbefore it completes restarts it, and the computations from earlier calls then fail.swas stopped withstopbefore completing, return anAsynccomputation that fails.
Equations
Instances For
If:
sis still running this stopsswithout completing any remainingAsynccomputations that were created throughwait. Those computations fail once the last reference to their promise is dropped, rather than producing a value.sis not yet or not anymore running this is a no-op.
Instances For
Create a Selector that resolves once s has finished. s only starts when it runs inside of a
Selectable. Every select or Selectable.tryOne that checks s before it has finished starts it again
from duration, so a Sleep that is checked more often than duration never finishes.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Return an Async computation that completes after duration.
Equations
- Std.Async.sleep duration = do let sleeper ← Std.Async.Sleep.mk duration sleeper.wait
Instances For
Return a Selector that completes after duration.
Equations
- Std.Async.Selector.sleep duration = do let sleeper ← Std.Async.Sleep.mk duration pure sleeper.selector
Instances For
Interval can be used to repeatedly wait for some duration like a clock.
The underlying timer has millisecond resolution.
- ofNative :: (
- native : Internal.UV.Timer
- )
Instances For
Setup up an Interval that waits for duration milliseconds.
This function only initializes but does not yet start the timer.
Equations
- Std.Async.Interval.mk duration x✝ = do let native ← Std.Internal.UV.Timer.mk (Std.Async.timeoutOf✝ duration) true pure { native := native }
Instances For
If:
iis not yet running start it and return anAsynccomputation that completes right away as the 0th multiple ofdurationhas elapsed.iis already running and:- the tick from the last call of
ihas not yet finished return the sameAsynccomputation as the last call - the tick from the last call of
ihas finished return a newAsynccomputation that waits for the closest next tick from the time of calling this function.
- the tick from the last call of
iis not running anymore, the returnedAsynccomputation fails, asstopdropped the promise it would have completed.
Equations
Instances For
If:
Interval.tickwas called onibefore the timer restarts counting from now and the next tick happens induration.iis not yet or not anymore running this is a no-op.
Instances For
If:
iis still running this stopsiwithout completing any remainingAsynccomputations that were created throughtick. Those computations fail once the last reference to their promise is dropped, rather than producing a value.iis not yet or not anymore running this is a no-op.