fix signal dont triggered bug in collectAll & slot::emplace()#414
Merged
ChuanqiXu9 merged 1 commit intoalibaba:mainfrom Jan 23, 2025
Merged
fix signal dont triggered bug in collectAll & slot::emplace()#414ChuanqiXu9 merged 1 commit intoalibaba:mainfrom
ChuanqiXu9 merged 1 commit intoalibaba:mainfrom
Conversation
Collaborator
Author
|
@ChuanqiXu9 All ci passed |
ChuanqiXu9
reviewed
Jan 23, 2025
| } | ||
| func(); | ||
| } | ||
| _event.setAwaitingCoro(continuation); |
Collaborator
There was a problem hiding this comment.
Now the coroutine may be suspended forever if the input was empty.
ChuanqiXu9
approved these changes
Jan 23, 2025
Collaborator
ChuanqiXu9
left a comment
There was a problem hiding this comment.
The variadic version has a static_assert for the inputs size.
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
slot::emplace()When we call
slot::emplace(), we check signal state before construct handler. however, whensignal::emit()called, it will set signal state then set the construct handler.A possible order:
slot::emplace()check signal state, no triggered now.slot::emplace()construct signal handler.signal::emit()set signal statesignal::emit()load signal handler and found it'snullptr, emit overslot::emplace()set the signal handler by CAS successful. return true.Now,
slot::emplace()will return true and signal handler won't be executed. the signal is loss.collectAnycollectAnyshould emit signal when the first handler resume, but now it may won't emit it ifdownCountwas called inawait_suspendWhat is changing
slot::emplace()slot::emplace()will construct signal handler before check signal state.Because
signal::emit()will always set state before load signal handler. so ifsignal::emit()load signal handler result isnullptr,slot::emplace()will always get the signal by check state.collectAll and collectAny
Remove
downCountcall inawait_suspendExample