-
Notifications
You must be signed in to change notification settings - Fork 531
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
Introduce raceOutcomeBoth
#3232
Introduce raceOutcomeBoth
#3232
Conversation
Crap, this was a false generalization.
I've currently implemented I have to think about this. |
/** | ||
* Races the evaluation of two fibers, cancels the loser, and returns the [[Outcome]] of both. | ||
* If the race is canceled before one or both participants complete, then then whichever ones | ||
* are incomplete are canceled. |
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.
I may be misunderstanding the intention, but this doesn't seem to be true: if one is canceled, and then the race is canceled while trying the join the other, then the other will not be canceled.
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.
Ah, thanks. I think the scaladoc was expressing my intent, I just screwed up the implementation 😅
case Left((oca, f)) => | ||
val joined = | ||
if (oca.isCanceled) | ||
poll(f.join) |
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.
See above, if we're canceled here, f
will not be canceled.
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.
You're right, I think this needs an .onCancel(f.cancel)
. And same below.
case Right((f, ocb)) => | ||
val joined = | ||
if (ocb.isCanceled) | ||
poll(f.join) |
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.
As above.
This allows us to generalize over
raceOutcome
andrace
. The motivation for this is to be able to handle the race condition where both fibers succeed, even though the loser is canceled. More on that in a follow-up PR.If this merges then I think I need to re-do #3226 in terms of
raceOutcomeBoth
instead.