now
The current “time” for this event loop. This is an amount in nanoseconds.
- iOS
- 13.0+
- macOS
- 10.15+
- tvOS
- 13.0+
- watchOS
- 6.0+
var now: NIODeadline { get }The current “time” for this event loop. This is an amount in nanoseconds.
var now: NIODeadline { get }s11NIOEmbedded24NIOAsyncTestingEventLoopC3now7NIOCore11NIODeadlineVvp What are these?1X0SBimport NIOEmbeddedfinal class NIOAsyncTestingEventLoopAn EventLoop that is thread safe and whose execution is fully controlled by the user.
struct NIODeadlineRepresents a point in time.
init() Initialize a new NIOAsyncTestingEventLoop.
var inEventLoop: Bool { get }func _executeIsolatedUnsafeUnchecked(_ task: @escaping () -> Void) func _preconditionSafeToSyncShutdown(file: StaticString, line: UInt) func _preconditionSafeToWait(file: StaticString, line: UInt) func _promiseCompleted(futureIdentifier: _NIOEventLoopFutureIdentifier) -> (file: StaticString, line: UInt)? func _promiseCreated(futureIdentifier: _NIOEventLoopFutureIdentifier, file: StaticString, line: UInt) @discardableResult func _scheduleTaskIsolatedUnsafeUnchecked<T>(deadline: NIODeadline, _ task: @escaping () throws -> T) -> Scheduled<T> @discardableResult func _scheduleTaskIsolatedUnsafeUnchecked<T>(in delay: TimeAmount, _ task: @escaping () throws -> T) -> Scheduled<T> func _submitIsolatedUnsafeUnchecked<T>(_ task: @escaping () throws -> T) -> EventLoopFuture<T> func advanceTime(by increment: TimeAmount) async Runs the event loop and moves “time” forward by the given amount, running any scheduled tasks that need to be run.
func advanceTime(to deadline: NIODeadline) async Runs the event loop and moves “time” forward to the given point in time, running any scheduled tasks that need to be run.
@preconcurrency func execute(_ task: @escaping () -> Void) On an NIOAsyncTestingEventLoop, execute will simply use scheduleTask with a deadline of now. Unlike with the other operations, this will immediately execute, to eliminate a common class of bugs.
func executeInContext<ReturnType>(_ task: @escaping () throws -> ReturnType) async throws -> ReturnType where ReturnType : Sendable Executes the given function in the context of this event loop. This is useful when it’s necessary to be confident that an operation is “blocking” the event loop. As long as you are executing, nothing else can execute in this loop.
func preconditionInEventLoop(file: StaticString, line: UInt) func preconditionNotInEventLoop(file: StaticString, line: UInt) func run() async Run all tasks that have previously been submitted to this NIOAsyncTestingEventLoop, either by calling execute or events that have been enqueued using scheduleTask/scheduleRepeatedTask/scheduleRepeatedAsyncTask and whose deadlines have expired.
@preconcurrency func scheduleCallback(at deadline: NIODeadline, handler: some NIOScheduledCallbackHandler & Sendable) throws -> NIOScheduledCallback @discardableResult @preconcurrency func scheduleCallback(in amount: TimeAmount, handler: some NIOScheduledCallbackHandler & Sendable) throws -> NIOScheduledCallback @discardableResult @preconcurrency func scheduleTask<T>(deadline: NIODeadline, _ task: @escaping () throws -> T) -> Scheduled<T> @discardableResult @preconcurrency func scheduleTask<T>(in: TimeAmount, _ task: @escaping () throws -> T) -> Scheduled<T> func shutdownGracefully() async The concurrency-aware equivalent of shutdownGracefully(queue:_:).
@preconcurrency func shutdownGracefully(queue: DispatchQueue, _ callback: @escaping ((any Error)?) -> Void)