Options for configuring the event loop behavior.
- accumulateIdleTime : Bool
Accumulate the amount of idle time the event loop spends in the event provider.
- blockSigProfSignal : Bool
Block a SIGPROF signal when polling for new events. It's commonly used for unnecessary wakeups when using a sampling profiler.
Instances For
Configures the event loop with the specified options.
Checks if the event loop is still active and processing events.
Timer
s are used to generate IO.Promise
s that resolve after some time.
A Timer
can be in one of 3 states:
- Right after construction it's initial.
- While it is ticking it's running.
- If it has stopped for some reason it's finished.
This together with whether it was set up as repeating
with Timer.new
determines the behavior
of all functions on Timer
s.
Instances For
This creates a Timer
in the initial state and doesn't run it yet.
- If
repeating
isfalse
this constructs a timer that resolves once afterdurationMs
milliseconds, counting from when it's run. - If
repeating
istrue
this constructs a timer that resolves after multiples ofdurationMs
milliseconds, counting from when it's run. Note that this includes the 0th multiple right after starting the timer. Furthermore a repeating timer will only be freed afterTimer.stop
is called.
This function has different behavior depending on the state and configuration of the Timer
:
- if
repeating
isfalse
and:- it is initial, run it and return a new
IO.Promise
that is set to resolve oncedurationMs
milliseconds have elapsed. After thisIO.Promise
is resolved theTimer
is finished. - it is running or finished, return the same
IO.Promise
that the first call tonext
returned.
- it is initial, run it and return a new
- if
repeating
istrue
and:- it is initial, run it and return a new
IO.Promise
that resolves right away (as it is the 0th multiple ofdurationMs
). - it is running, check whether the last returned
IO.Promise
is already resolved:- If it is, return a new
IO.Promise
that resolves upon finishing the next cycle - If it is not, return the last
IO.Promise
This ensures that the returnedIO.Promise
resolves at the next repetition of the timer.
- If it is, return a new
- if it is finished, return the last
IO.Promise
created bynext
. Notably this could be one that never resolves if the timer was stopped before fulfilling the last one.
- it is initial, run it and return a new
This function has different behavior depending on the state and configuration of the Timer
:
- If it is initial or finished this is a no-op.
- If it is running and
repeating
isfalse
this will delay the resolution of the timer untildurationMs
milliseconds after the call of this function. - Delay the resolution of the next tick of the timer until
durationMs
milliseconds after the call of this function, then continue normal ticking behavior from there.
This function has different behavior depending on the state of the Timer
:
- If it is initial or finished this is a no-op.
- If it is running the execution of the timer is stopped and it is put into the finished state.
Note that if the last
IO.Promise
generated bynext
is unresolved and being waited on this creates a memory leak and the waiting task is not going to be awoken anymore.