public final 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.

Time is controllable on an EmbeddedEventLoop. It begins at NIODeadline.uptimeNanoseconds(0) and may be advanced by a fixed amount by using advanceTime(by:), or advanced to a point in time with advanceTime(to:).


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.