mirror of
https://github.com/apple/swift-nio
synced 2026-11-24 04:37:54 +00:00
* Enhance and rename AsyncEmbeddedEventLoop Motivation AsyncEmbeddedEventLoop is an important part of our ongoing testing story for NIO. However, it suffers from two problems. The first is a usability one. As we discovered during the original implementation, following EmbeddedEventLoop's pattern of not having any EventLoop "Tasks" execute until run() meant that simple constructs like `EventLoopFuture.wait` and `EventLoopFuture.get` didn't work at all, forcing us to add an annoying `awaitFuture` method. When playing with implementing EmbeddedChannel, this got worse, as I/O methods also don't run immediately if called from the testing thread. We couldn't easily work around this issue, and it meant that common patterns (like calling `channel.writeAndFlush`) would deadlock! This is unacceptable, so a change had to be made. While we're here, we received feedback that the name is unclear to users. Given that this particular event loop is in no sense "embedded", we no longer need the name, so we can take this opportunity to use a better one. Modifications Changed `func execute` to immediately execute its task body, and to dequeue all pending tasks at this time. Essentially, it's the equivalent to run(). This is a major change in its behaviour. Renamed the loop to `NIOAsyncTestingEventLoop`. Result Better names, easier to use. * Make soundness happy * Remove awaitFuture