Ordering::Acquire

Acquire is an ordering that deals with loads. Recall that we previously said that if a thread, B, loads var with Acquire ordering and thread A then stores with Release ordering, then A synchronizes-with B, which means that A happens-before B. Recall that back in the previous chapter we ran into Acquire in the context of hopper:

 pub unsafe fn push_back( &self, elem: T, guard: &mut MutexGuard<BackGuardInner<S>>, ) -> Result<bool, Error<T>> { let mut must_wake_dequeuers = false; if self.size.load(Ordering::Acquire) == self.capacity { return Err(Error::Full(elem)); } else { assert!((*self.data.offset((*guard).offset)).is_none()); *self.data.offset((*guard).offset) = Some(elem); (*guard).offset += 1; (*guard).offset %= self.capacity ...

Get Hands-On Concurrency with Rust now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.