Fix race condition in SingleThreadSynchronizationContext#4468
Conversation
roji
left a comment
There was a problem hiding this comment.
Apart from the exception flow, LGTM - I can't see a problem. Though seeing the complexity here - for code which isn't supposed to be perf-critical - I tend to agree with @NinoFloris's offline comment that we could sacrifice extreme perf here and go with a locking approach in order to have simpler/safer code. If needed I think I'd also be OK with just keeping the thread around (i.e. removing the timeout), which would obviously simplify this a lot.
But am also OK with keeping this lock-free code if we really want to (after the exception flow is fixed).
@NinoFloris can we have your pair of eyes on this too?
|
@roji @NinoFloris thinking a bit more, I do agree that making this as simple as possible is a much better solution (we can always rewrite, if for some reason it's going to be a bottleneck). I changed it to a |
roji
left a comment
There was a problem hiding this comment.
Thanks for simplifying - this looks great and far less magical/tricky :)
Looks safe to me - see minor comments. @NinoFloris can you give this a review too please?
NinoFloris
left a comment
There was a problem hiding this comment.
Modulo the feedback by @roji LGTM!
Fixes #4465
I think it should be fine...