waitSpinningRunLoop(inMode:file:line:)
Wait for the resolution of this EventLoopFuture
by spinning RunLoop.current
in mode
until the future resolves. The calling thread will be blocked albeit running RunLoop.current
.
func waitSpinningRunLoop(inMode mode: RunLoop.Mode = .default, file: StaticString = #file, line: UInt = #line) throws -> Value where Value : Sendable
Returns
The value of the EventLoopFuture
when it completes.
Throws
The error value of the EventLoopFuture
if it errors.
If the EventLoopFuture
resolves with a value, that value is returned from waitSpinningRunLoop()
. If the EventLoopFuture
resolves with an error, that error will be thrown instead. waitSpinningRunLoop()
will block whatever thread it is called on, so it must not be called on event loop threads: it is primarily useful for testing, or for building interfaces between blocking and non-blocking code.
This is also forbidden in async contexts: prefer EventLoopFuture/get()
.