-
Notifications
You must be signed in to change notification settings - Fork 656
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support hopping event loops with EventLoopFuture
Motivation: A somewhat common requirement when working with chains of futures is needing to hop from one event loop to another. This is particularly common when relying on the fact that EventLoopFuture will synchronize with the event loop that created it: you often want to rely on that implicit locking, rather than use Dispatch or Lock to achieve the same effect. While doing this hop requires relatively little code, it's not necessarily totally apparent to new users how they would do it. Additionally, the most naive implementation incurs the overhead of allocations and reference counting in cases where it's not necessary (e.g. when you have only one event loop, or when both work items are being scheduled on the same event loop). For this reason, we should have a nice concise way for a user to request this behaviour and get a relatively performant implementation of the behaviour. Modifications: Added EventLoopFuture<T>.on(eventLoop:). Changed AcceptHandler to use the new method rather than its (slower) alternative. Result: Users will have an easier time working with EventLoopFutures.
- Loading branch information
Showing
4 changed files
with
74 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters