scheduleCallback(in:handler:)
Schedule a callback after given time.
@discardableResult @preconcurrency func scheduleCallback(in amount: TimeAmount, handler: some (NIOScheduledCallbackHandler & Sendable)) throws -> NIOScheduledCallback
Schedule a callback after given time.
@discardableResult @preconcurrency func scheduleCallback(in amount: TimeAmount, handler: some (NIOScheduledCallbackHandler & Sendable)) throws -> NIOScheduledCallback
s7NIOCore9EventLoopP16scheduleCallback2in7handlerAA012NIOScheduledE0VAA10TimeAmountV_qd__tKAA0hE7HandlerRd__lF
What are these?5DDQK
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.
struct TimeAmount
Represents a time interval.
protocol NIOScheduledCallbackHandler
A type that handles callbacks scheduled with EventLoop.scheduleCallback(at:handler:)
.
protocol Sendable
struct NIOScheduledCallback
An opaque handle that can be used to cancel a scheduled callback.
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.
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.
func cancelScheduledCallback(_ scheduledCallback: NIOScheduledCallback)
Cancel a scheduled callback.
func enqueue(_ job: consuming ExecutorJob)
Submit a job to be executed by the EventLoop
@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 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.
@discardableResult @preconcurrency func scheduleCallback(in amount: TimeAmount, handler: some (NIOScheduledCallbackHandler & Sendable)) throws -> NIOScheduledCallback
Default implementation of scheduleCallback(in amount:handler:)
: calls scheduleCallback(at deadline:handler:)
.