EmbeddedEventLoop

public class EmbeddedEventLoop : EventLoop

An EventLoop that is embedded in the current running context with no external control.

Unlike more complex EventLoops, such as SelectableEventLoop, the EmbeddedEventLoop has no proper eventing mechanism. Instead, reads and writes are fully controlled by the entity that instantiates the EmbeddedEventLoop. This property makes EmbeddedEventLoop of limited use for many application purposes, but highly valuable for testing and other kinds of mocking.

Warning

Unlike SelectableEventLoop, EmbeddedEventLoop is 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 EmbeddedEventLoop in an unsynchronized fashion.
  • Declaration

    Swift

    public var inEventLoop: Bool { get }
  • Undocumented

    Declaration

    Swift

    public init()
  • Declaration

    Swift

    public func scheduleTask<T>(in: TimeAmount, _ task: @escaping () throws -> T) -> Scheduled<T>
  • Declaration

    Swift

    public func execute(_ task: @escaping () -> Void)
  • Undocumented

    Declaration

    Swift

    public func run()
  • Runs the event loop and moves time forward by the given amount, running any scheduled tasks that need to be run.

    Declaration

    Swift

    public func advanceTime(by: TimeAmount)
  • Declaration

    Swift

    public func shutdownGracefully(queue: DispatchQueue, _ callback: @escaping (Error?) -> Void)