@@ -129,7 +129,7 @@ impl<T> Packet<T> {
129129 let ptr = unsafe { signal_token. cast_to_usize ( ) } ;
130130
131131 // 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 ( ) {
133133 if let Some ( deadline) = deadline {
134134 let timed_out = !wait_token. wait_max_until ( deadline) ;
135135 // Try to reset the state
@@ -161,7 +161,12 @@ impl<T> Packet<T> {
161161 // the state changes under our feet we'd rather just see that state
162162 // change.
163163 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+ ) ;
165170 match ( & mut * self . data . get ( ) ) . take ( ) {
166171 Some ( data) => Ok ( data) ,
167172 None => unreachable ! ( ) ,
@@ -264,7 +269,10 @@ impl<T> Packet<T> {
264269
265270 // If we've got a blocked thread, then use an atomic to gain ownership
266271 // 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) ,
268276 } ;
269277
270278 // Now that we've got ownership of our state, figure out what to do
0 commit comments