enqueue(_:)
Submit a job to be executed by the EventLoop
- iOS
- 17.0+
- macOS
- 14.0+
- tvOS
- 17.0+
- watchOS
- 10.0+
func enqueue(_ job: consuming ExecutorJob)
Submit a job to be executed by the EventLoop
func enqueue(_ job: consuming ExecutorJob)
s7NIOCore9EventLoopP7enqueueyy12_Concurrency11ExecutorJobVnF
What are these?1Y326
import NIOCore
The core abstractions that make up SwiftNIO.
protocol EventLoop : EventLoopGroup
An EventLoop processes IO / tasks in an endless loop for Channel
s until it’s closed.
@frozen struct ExecutorJob
A unit of schedulable work.
var executor: any SerialExecutor { get }
Returns a SerialExecutor
corresponding to this EventLoop
.
var inEventLoop: Bool { get }
Returns true
if the current NIOThread
is the same as the NIOThread
that is tied to this EventLoop
. false
otherwise.
var now: NIODeadline { get }
The current time of the event loop.
func _executeIsolatedUnsafeUnchecked(_ task: @escaping () -> Void)
Submit a given task to be executed by the EventLoop
, from a context where the caller statically knows that the context is isolated.
func _preconditionSafeToWait(file: StaticString, line: UInt)
Must crash if it is not safe to call wait()
on an EventLoopFuture
.
func _promiseCompleted(futureIdentifier: _NIOEventLoopFutureIdentifier) -> (file: StaticString, line: UInt)?
Debug hook: complete a specific promise and return its creation location.
func _promiseCreated(futureIdentifier: _NIOEventLoopFutureIdentifier, file: StaticString, line: UInt)
Debug hook: track a promise creation and its location.
@discardableResult func _scheduleTaskIsolatedUnsafeUnchecked<T>(deadline: NIODeadline, _ task: @escaping () throws -> T) -> Scheduled<T>
Schedule a task
that is executed by this EventLoop
at the given time, from a context where the caller statically knows that the context is isolated.
@discardableResult func _scheduleTaskIsolatedUnsafeUnchecked<T>(in: TimeAmount, _ task: @escaping () throws -> T) -> Scheduled<T>
Schedule a task
that is executed by this EventLoop
after the given amount of time, from a context where the caller statically knows that the context is isolated.
func _submitIsolatedUnsafeUnchecked<T>(_ task: @escaping () throws -> T) -> EventLoopFuture<T>
Submit a given task to be executed by the ``EventLoop```, from a context where the caller statically knows that the context is isolated.
func cancelScheduledCallback(_ scheduledCallback: NIOScheduledCallback)
Cancel a scheduled callback.
@preconcurrency func execute(_ task: @escaping () -> Void)
Submit a given task to be executed by the EventLoop
func makeSucceededVoidFuture() -> EventLoopFuture<Void>
Return a succeeded Void
future.
func preconditionInEventLoop(file: StaticString, line: UInt)
Asserts that the current thread is the one tied to this EventLoop
. Otherwise, the process will be abnormally terminated as per the semantics of preconditionFailure(_:file:line:)
.
func preconditionNotInEventLoop(file: StaticString, line: UInt)
Asserts that the current thread is not the one tied to this EventLoop
. Otherwise, the process will be abnormally terminated as per the semantics of preconditionFailure(_:file:line:)
.
@discardableResult @preconcurrency func scheduleCallback(at deadline: NIODeadline, handler: some (NIOScheduledCallbackHandler & Sendable)) throws -> NIOScheduledCallback
Schedule a callback at a given time.
@discardableResult @preconcurrency func scheduleCallback(in amount: TimeAmount, handler: some (NIOScheduledCallbackHandler & Sendable)) throws -> NIOScheduledCallback
Schedule a callback after given time.
@discardableResult @preconcurrency func scheduleTask<T>(deadline: NIODeadline, _ task: @escaping () throws -> T) -> Scheduled<T>
Schedule a task
that is executed by this EventLoop
at the given time.
@discardableResult @preconcurrency func scheduleTask<T>(in: TimeAmount, _ task: @escaping () throws -> T) -> Scheduled<T>
Schedule a task
that is executed by this EventLoop
after the given amount of time.
@preconcurrency func submit<T>(_ task: @escaping () throws -> T) -> EventLoopFuture<T>
Submit a given task to be executed by the EventLoop
. Once the execution is complete the returned EventLoopFuture
is notified.
func enqueue(_ job: consuming ExecutorJob)
func enqueue(_ job: consuming ExecutorJob)