@@ -129,7 +129,7 @@ impl<T> Packet<T> {
129
129
let ptr = unsafe { signal_token. cast_to_usize ( ) } ;
130
130
131
131
// race with senders to enter the blocking state
132
- if self . state . compare_and_swap ( EMPTY , ptr, Ordering :: SeqCst ) == EMPTY {
132
+ if self . state . compare_exchange ( EMPTY , ptr, Ordering :: SeqCst , Ordering :: SeqCst ) . is_ok ( ) {
133
133
if let Some ( deadline) = deadline {
134
134
let timed_out = !wait_token. wait_max_until ( deadline) ;
135
135
// Try to reset the state
@@ -161,7 +161,12 @@ impl<T> Packet<T> {
161
161
// the state changes under our feet we'd rather just see that state
162
162
// change.
163
163
DATA => {
164
- self . state . compare_and_swap ( DATA , EMPTY , Ordering :: SeqCst ) ;
164
+ let _ = self . state . compare_exchange (
165
+ DATA ,
166
+ EMPTY ,
167
+ Ordering :: SeqCst ,
168
+ Ordering :: SeqCst ,
169
+ ) ;
165
170
match ( & mut * self . data . get ( ) ) . take ( ) {
166
171
Some ( data) => Ok ( data) ,
167
172
None => unreachable ! ( ) ,
@@ -264,7 +269,10 @@ impl<T> Packet<T> {
264
269
265
270
// If we've got a blocked thread, then use an atomic to gain ownership
266
271
// of it (may fail)
267
- ptr => self . state . compare_and_swap ( ptr, EMPTY , Ordering :: SeqCst ) ,
272
+ ptr => self
273
+ . state
274
+ . compare_exchange ( ptr, EMPTY , Ordering :: SeqCst , Ordering :: SeqCst )
275
+ . unwrap_or_else ( |x| x) ,
268
276
} ;
269
277
270
278
// Now that we've got ownership of our state, figure out what to do
0 commit comments