DispatchQueue

extension DispatchQueue
  • Schedules a work item for immediate execution and immediately returns with an EventLoopFuture providing the result. For example:

    let futureResult = DispatchQueue.main.asyncWithFuture(eventLoop: myEventLoop) { () -> String in
        callbackMayBlock()
    }
    try let value = futureResult.wait()
    

    Declaration

    Swift

    @inlinable
    public func asyncWithFuture<NewValue>(
        eventLoop: EventLoop,
        _ callbackMayBlock: @escaping () throws -> NewValue
    ) -> EventLoopFuture<NewValue>

    Parameters

    eventLoop

    the EventLoop on which to proceses the IO / task specified by callbackMayBlock.

    callbackMayBlock

    The scheduled callback for the IO / task.