Instance Method
sleep(for:)
Suspends the current task for duration, driven by this event loop.
func sleep(for duration: Duration) async
Parameters
-
duration
-
How long to suspend. Negative or zero durations return on the next loop iteration.
Mentioned In
Discussion
Unlike Task.sleep(for:), which goes through the global Swift concurrency clock, this routes the wait through libevent’s timer wheel — useful when you want sleeps to share scheduling with the same multiplexer that’s driving your I/O. Internally registers a one-shot timer via schedule(after:_:) and drives the loop until it fires.