swift-nio
swift-nio copied to clipboard
Add a new overloading function completeWith to EventLoopPromise class.
Add a new overloading function completeWith to EventLoopPromise class.
Motivation:
- Replace global helper function executeAndComplete() with class method for better encapsulation.
- Get rid of the repeated pattern of checking whether the event loop is "current".
Modifications:
- Removed global function executeAndComplete().
- Added a new overloading of the completeWith() method to EventLoopPromise class.
Result:
Simplified the consumers of this functionality in code. And the new added overloading supports crossing event loop as well.
Can one of the admins verify this patch?
Can one of the admins verify this patch?
Can one of the admins verify this patch?
Can one of the admins verify this patch?
Can one of the admins verify this patch?
Can one of the admins verify this patch?
Can one of the admins verify this patch?
Can one of the admins verify this patch?
Can one of the admins verify this patch?
Can one of the admins verify this patch?
Can one of the admins verify this patch?
Thanks for this patch! Out of curiosity, is it necessary to hop the loop? EventLoopPromise
is entirely thread-safe and can absolutely be executed on any thread. Unless you have a specific reason to want to do the loop hopping, I think we can safely remove that from this.
Thanks for this patch! Out of curiosity, is it necessary to hop the loop?
EventLoopPromise
is entirely thread-safe and can absolutely be executed on any thread. Unless you have a specific reason to want to do the loop hopping, I think we can safely remove that from this.
@Lukasa there is no specific reason for me to do the loop hopping, I was just trying to keep the original logics as much as possible. I'm little confused about what you are referring to remove, can you please give me some hints and I can look at it more closely.
The original logic of the exact function you're replacing didn't do if eventLoop.inEventLoop
and then conditionally call execute
. This is not really necessary, and can be removed.