public final class EmbeddedEventLoop : EventLoop
EventLoop that is embedded in the current running context with no external
Unlike more complex
EventLoops, such as
has no proper eventing mechanism. Instead, reads and writes are fully controlled by the
entity that instantiates the
EmbeddedEventLoop. This property makes
of limited use for many application purposes, but highly valuable for testing and other
kinds of mocking.
EmbeddedEventLoopis not thread-safe. This is because it is intended to be run in the thread that instantiated it. Users are responsible for ensuring they never call into the
EmbeddedEventLoopin an unsynchronized fashion.
Initialize a new
executewill simply use
scheduleTaskwith a deadline of now. This means that
taskwill be run the next time you call
public func execute(_ task: @escaping () -> Void)
Run all tasks that have previously been submitted to this
EmbeddedEventLoop, either by calling
executeor events that have been enqueued using
scheduleRepeatedAsyncTaskand whose deadlines have expired.
public func run()
public func shutdownGracefully(queue: DispatchQueue, _ callback: @escaping (Error?) -> Void)