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

Add operator overloading to atomic types. #7423

Closed
Aatch opened this issue Jun 27, 2013 · 4 comments
Closed

Add operator overloading to atomic types. #7423

Aatch opened this issue Jun 27, 2013 · 4 comments

Comments

@Aatch
Copy link
Contributor

Aatch commented Jun 27, 2013

The C++ atomic types overload specified operators, defaulting to a sequentially consistent ordering, we should do the same.

Due to the semantics of atomic operations, however, this is blocked on assignment operator overloading (since a += b is a different operation to c = a + b) (#5992)

@brson
Copy link
Contributor

brson commented Jun 27, 2013

This worries me a bit. Using overloaded operators for atomics seems prone to abuse or misuse. Using methods makes it clear something special's going on, order of evaluation doesn't depend on operator precedence. I believe that evaluating complex math with atomics is not common.

@thestinger
Copy link
Contributor

Visiting for triage, I agree that these are unlikely to be used very often and could cause confusion. I think almost every use case for atomics in Rust will be to implement concurrent data structures, with a rare case of a static mut atomic like a global counter for debugging or performance statistics.

They aren't really part of the user-level concurrency idioms in Rust (message passing), so it's okay if they aren't pretty.

@sanxiyn
Copy link
Member

sanxiyn commented Dec 29, 2013

Triage. Do we actually want this? I personally don't. While "C++ does it" is usually a good argument, it is not an absolute argument.

@alexcrichton
Copy link
Member

Closing this due to the general opinion being that atomics should force you to think about memory ordering and related semantics.

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

No branches or pull requests

5 participants