-
Notifications
You must be signed in to change notification settings - Fork 263
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
feat: Substitute mutex with atomic operations. #622
Conversation
Use atomic operations instead a mutex. This approach avoids locking and increment can be done within a single clock cycle, hence no deadlock nor race condition can occur. Signed-off-by: Ville Valkonen <weezel@users.noreply.github.com>
A gentle one week bump |
A gentle two weeks bump |
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.
Looks good to me! Will get another team member to also confirm before merging :)
Thanks for your patience with this one @weezel. If we think this makes sense we should probably do this across the board in Bubbles where we employ this pattern (for example, in Before we merge this we should also look into why this is failing in CI. |
lastID.Add(1) | ||
return int(lastID.Load()) |
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.
add returns the new value, so this can be:
lastID.Add(1) | |
return int(lastID.Load()) | |
return int(lastID.Add(1)) |
|
closes #622 Signed-off-by: Carlos Alexandro Becker <caarlos0@users.noreply.github.com>
closes #622 Signed-off-by: Carlos Alexandro Becker <caarlos0@users.noreply.github.com>
Unless there are any negative implications, let’s maintain 1.18 compatibility. |
closes #622 Signed-off-by: Carlos Alexandro Becker <caarlos0@users.noreply.github.com> Co-authored-by: Ville Valkonen <weezel@users.noreply.github.com>
closes #622 Signed-off-by: Carlos Alexandro Becker <caarlos0@users.noreply.github.com> Co-authored-by: Ville Valkonen <weezel@users.noreply.github.com>
Thanking you 😊👍 |
Use atomic operations instead a mutex. This approach avoids locking and increment can be done within a single clock cycle, hence no deadlock nor race condition can occur.