diff options
author | Haibo Huang <hhb@google.com> | 2021-02-09 18:18:56 -0800 |
---|---|---|
committer | Stephen Hines <srhines@google.com> | 2021-03-03 21:34:52 +0000 |
commit | e3d8d80d2d8744ccdcd175323e0864c8f30fcedc (patch) | |
tree | 16d053e70d21e456d52f4a7762ee41441342b7a2 /src/sync/mpsc/block.rs | |
parent | 925d648e545e70d6a4faae3d7efe5e0de885f922 (diff) | |
download | tokio-e3d8d80d2d8744ccdcd175323e0864c8f30fcedc.tar.gz |
Upgrade rust/crates/tokio to 1.2.0
Test: make
Change-Id: Ib0f6a5201b51e9d122b6e867388a3856e16f803a
Diffstat (limited to 'src/sync/mpsc/block.rs')
-rw-r--r-- | src/sync/mpsc/block.rs | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/src/sync/mpsc/block.rs b/src/sync/mpsc/block.rs index e062f2b..6bef794 100644 --- a/src/sync/mpsc/block.rs +++ b/src/sync/mpsc/block.rs @@ -258,13 +258,15 @@ impl<T> Block<T> { pub(crate) unsafe fn try_push( &self, block: &mut NonNull<Block<T>>, - ordering: Ordering, + success: Ordering, + failure: Ordering, ) -> Result<(), NonNull<Block<T>>> { block.as_mut().start_index = self.start_index.wrapping_add(BLOCK_CAP); let next_ptr = self .next - .compare_and_swap(ptr::null_mut(), block.as_ptr(), ordering); + .compare_exchange(ptr::null_mut(), block.as_ptr(), success, failure) + .unwrap_or_else(|x| x); match NonNull::new(next_ptr) { Some(next_ptr) => Err(next_ptr), @@ -306,11 +308,11 @@ impl<T> Block<T> { // // `Release` ensures that the newly allocated block is available to // other threads acquiring the next pointer. - let next = NonNull::new(self.next.compare_and_swap( - ptr::null_mut(), - new_block.as_ptr(), - AcqRel, - )); + let next = NonNull::new( + self.next + .compare_exchange(ptr::null_mut(), new_block.as_ptr(), AcqRel, Acquire) + .unwrap_or_else(|x| x), + ); let next = match next { Some(next) => next, @@ -333,7 +335,7 @@ impl<T> Block<T> { // TODO: Should this iteration be capped? loop { - let actual = unsafe { curr.as_ref().try_push(&mut new_block, AcqRel) }; + let actual = unsafe { curr.as_ref().try_push(&mut new_block, AcqRel, Acquire) }; curr = match actual { Ok(_) => { |