Skip to content
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

Modify Bool to only use 1 or 0, rater than last bit #62

Merged
merged 2 commits into from
Nov 19, 2019

Conversation

prashantv
Copy link
Collaborator

Most methods of Bool currently rely on the last bit, but CAS
generates the int value to match old based on the user's input
and so it assumes the value is either 1 or 0.

The only reason we relid on the last bit is that Toggle was
implemented using an atomic add. We can instead implement
Toggle using a loop around CAS.

Fixes #61.

Most methods of Bool currently rely on the last bit, but `CAS`
generates the int value to match `old` based on the user's input
and so it assumes the value is either `1` or `0`.

The only reason we relid on the last bit is that `Toggle` was
implemented using an atomic add. We can instead implement
`Toggle` using a loop around `CAS`.

Fixes #61.
@codecov
Copy link

codecov bot commented Nov 19, 2019

Codecov Report

Merging #62 into master will not change coverage.
The diff coverage is 100%.

Impacted file tree graph

@@          Coverage Diff          @@
##           master    #62   +/-   ##
=====================================
  Coverage     100%   100%           
=====================================
  Files           3      3           
  Lines         145    148    +3     
=====================================
+ Hits          145    148    +3
Impacted Files Coverage Δ
atomic.go 100% <100%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update b99530f...fc1544f. Read the comment docs.

Copy link
Collaborator

@abhinav abhinav left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I'd rather keep CAS optimal since that's the low-level primitive here.

@prashantv prashantv merged commit 40ae6a4 into master Nov 19, 2019
@prashantv prashantv deleted the bool_cas_toggle branch November 19, 2019 21:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Bool CAS and Toggle don't work together
2 participants