Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.
Sign upTracking issue for compare_exchange #31767
Comments
alexcrichton
added
B-RFC-approved
T-libs
labels
Feb 18, 2016
This comment has been minimized.
This comment has been minimized.
alexcrichton
added
B-unstable
and removed
B-RFC-approved
labels
Feb 22, 2016
This comment has been minimized.
This comment has been minimized.
|
Note that the FCP for this should also take into account that the stable compare_and_swap should be deprecated |
This comment has been minimized.
This comment has been minimized.
|
I'm having second thoughts about the return type of |
This comment has been minimized.
This comment has been minimized.
|
As @Amanieu says, is there a reason that fn compare_exchange_weak(&self, current: T, new: T, success: Ordering, failure: Ordering) -> Result<T, T>; It seems we forgot about this option on the RFC. Thoughts, @rust-lang/libs? |
This comment has been minimized.
This comment has been minimized.
|
I don't think a |
This comment has been minimized.
This comment has been minimized.
|
Hm, arguably both methods could return That'd at least unify the APIs, but @Amanieu is right in that |
This comment has been minimized.
This comment has been minimized.
|
I agree with @alexcrichton that both methods should return the same enum type for consistency. Note that this would require a breaking change the For reference, here is what I expect a typical // Load the initial value
let mut val = ATOMIC.load(Ordering::Relaxed);
loop {
// Do something with it and determine the new value
let new = do_something(val);
// Now attempt to atomically change the value to the new one
match ATOMIC.compare_exchange_weak(val, new, Ordering::Acquire, Ordering::Relaxed) {
// Success
(true, _) => break,
// Failure, we get the current value back. Use that to try again.
(false, old) => val = old,
}
} |
This comment has been minimized.
This comment has been minimized.
|
The intrinsics do not need to change, the exposed functions can wrap the raw return values up into something more Rusty, like we do for checked arithmetic. This approach is in fact significantly easier than getting the compiler to construct the right I don't think anyone would use (The first sentence makes me realise: it's somewhat unfortunate that we have Diving into the details, maybe the return value should be |
This comment has been minimized.
This comment has been minimized.
|
I personally recommended
I suspect many |
alexcrichton
added
the
I-nominated
label
Mar 9, 2016
This comment has been minimized.
This comment has been minimized.
|
cc me |
This comment has been minimized.
This comment has been minimized.
|
Should the |
This comment has been minimized.
This comment has been minimized.
|
I personally would prefer the name |
Amanieu
referenced this issue
Mar 14, 2016
Merged
Change compare_exchange to return a Result<T, T> #32244
bors
added a commit
that referenced
this issue
Mar 18, 2016
bors
added a commit
that referenced
this issue
Mar 19, 2016
bors
added a commit
that referenced
this issue
Mar 19, 2016
bors
added a commit
that referenced
this issue
Mar 19, 2016
bors
added a commit
that referenced
this issue
Mar 19, 2016
This comment has been minimized.
This comment has been minimized.
|
|
alexcrichton
added
final-comment-period
and removed
I-nominated
labels
Apr 29, 2016
This comment has been minimized.
This comment has been minimized.
|
Ah and as a plan of action the libs team proposes:
That way there is always a stable non-deprecated way to do compare and swap! |
This comment has been minimized.
This comment has been minimized.
|
The libs team discussed this during triage yesterday and the decision was to stabilize |
alexcrichton
added a commit
to alexcrichton/rust
that referenced
this issue
May 17, 2016
alexcrichton
added a commit
to alexcrichton/rust
that referenced
this issue
May 17, 2016
alexcrichton
referenced this issue
May 17, 2016
Merged
std: Stabilize APIs for the 1.10 release #33699
alexcrichton
added a commit
to alexcrichton/rust
that referenced
this issue
May 18, 2016
alexcrichton
added a commit
to alexcrichton/rust
that referenced
this issue
May 18, 2016
alexcrichton
added a commit
to alexcrichton/rust
that referenced
this issue
May 18, 2016
alexcrichton
added a commit
to alexcrichton/rust
that referenced
this issue
May 23, 2016
bors
added a commit
that referenced
this issue
May 23, 2016
alexcrichton
added a commit
to alexcrichton/rust
that referenced
this issue
May 23, 2016
bors
added a commit
that referenced
this issue
May 23, 2016
alexcrichton
added a commit
to alexcrichton/rust
that referenced
this issue
May 23, 2016
bors
added a commit
that referenced
this issue
May 24, 2016
alexcrichton
added a commit
to alexcrichton/rust
that referenced
this issue
May 24, 2016
bors
added a commit
that referenced
this issue
May 24, 2016
alexcrichton
added a commit
to alexcrichton/rust
that referenced
this issue
May 24, 2016
bors
added a commit
that referenced
this issue
May 25, 2016
bors
added a commit
that referenced
this issue
May 25, 2016
bors
added a commit
that referenced
this issue
May 26, 2016
bors
closed this
in
#33699
May 26, 2016
alexcrichton
added a commit
to alexcrichton/rust
that referenced
this issue
May 26, 2016
srinivasreddy
added a commit
to srinivasreddy/rust
that referenced
this issue
May 28, 2016
srinivasreddy
added a commit
to srinivasreddy/rust
that referenced
this issue
May 29, 2016
luser
referenced this issue
Dec 7, 2016
Closed
Document minimum required version of Rust + Cargo in README #39
This comment has been minimized.
This comment has been minimized.
|
It seems that we never got around to deprecating |
alexcrichton commentedFeb 18, 2016
Tracking issue for rust-lang/rfcs#1443