-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Decouple futures completion from dispatchers #6614
Conversation
@endragor, rumors say you could help test this. Could you please? =) |
Looks good to me.
|
@zielmicha, ok, added a comment. Hopefully it clears the things up a bit. I don't want to remove those procs to not introduce conflicts with dom's upcoming merge. All of those can later be removed completely from selectors along with pending callbacks logic. Though I could do that if @dom96 doesn't mind. |
c65d783
to
2a5fdea
Compare
I'm just curious, for what reason the name of this PR is "Decouple futures completion from selectors". |
Haha, good point, that should be "dispatchers" obviously. |
2a5fdea
to
cc1440a
Compare
@dom96 Please give some feedback. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is fine in general, but it feels very unintuitive. I can see at least one potential issue (see comment)
Also I'm pretty sure we've changed this code a few times now, how can we be certain that this is the correct approach? I'm not confident that the semantics this code introduces won't cause other problems, mainly because this code isn't easy to understand.
Does anyone here know of how other async implementations deal with this problem? I think it's time we evaluate those to get a better insight.
if pendingCallbacks.len == 1: | ||
var i = 0 | ||
while i < pendingCallbacks.len: | ||
pendingCallbacks[i]() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we end up in a situation where this line raises, causing pendingCallbacks.len
to be something higher than "1" and thus the above branch fails forever, leading to all callbacks not completing?
Ok, this means it's complex, will break code and seems to be another case of moving the problem around without solving much. IMHO this means this should be closed. |
I think we should discuss it instead of just closing it and forgetting about it. |
Co-Authored-By: yglukhov <[email protected]>
It's been a while, and I can see some downsides to this approach. Namely:
IMO these issues have to be sorted, otherwise merging this pr is just moving problems around, as @Araq says. Therefore, I suggest closing this. While it still remains a useful chunk of code, it is not sufficient on its own. |
Alright. Closing. |
This sudden idea is pretty trivial. This PR restores old future completion behavior that doesn't rely on selectors, and fixes the recursion problem differently.
callSoon
is now reentrant and launches callback processing only for the first callback. The benefits are that futures are now self sufficient and don't need a completion proc to complete properly. This also simplifies the implementation of selectors as they now don't need to care about pending futures. I will clean up the selectors code in this regards as soon as this (and probably upcoming) is merged. Please review.@Araq, @dom96, @zielmicha, @cheatfate.