pub unsafe fn atomic_load<T: Copy, L: FallbackLock>(lock: &L, src: *mut Option<T>) -> Option<T> {
    atomic! {
        Option<T>, a,
        {
            a = &*(src as *const _ as *const _);
            mem::transmute_copy(&a.load(Ordering::Acquire))
        },
        {
            // Try doing an optimistic read first.
            // We need a volatile read here because other threads might concurrently modify the
            // value. In theory, data races are *always* UB, even if we use volatile reads and
            // discard the data when a data race is detected. The proper solution would be to
            // do atomic reads and atomic writes, but we can't atomically read and write all
            // kinds of data since `AtomicU8` is not available on stable Rust yet.
            if let Ok(val) = lock.read_optimistic(|| ptr::read_volatile(src)) {
                val
            } else {
                // Grab a regular read lock so that writers don't starve this load.
                lock.read(|| ptr::read(src))
            }
        }
    }
}
/// Atomically reads data from `src`.
///
/// This operation uses the `Acquire` ordering. If possible, an atomic instructions is used, and a
/// global lock otherwise.
Atomically reads data from `src`.
This operation uses the `Acquire` ordering. If possible, an atomic instructions is used, and a
global lock otherwise.
Atomically reads data from ` src ` . This operation uses the ` Acquire ` ordering . If possible an atomic instructions is used and a global lock otherwise .
pub unsafe fn atomic_load<T: Copy, L: FallbackLock>(lock: &L, src: *mut Option<T>) -> Option<T> {
    atomic! {
        Option<T>, a,
        {
            a = &*(src as *const _ as *const _);
            mem::transmute_copy(&a.load(Ordering::Acquire))
        },
        {
            // Try doing an optimistic read first.
            // We need a volatile read here because other threads might concurrently modify the
            // value. In theory, data races are *always* UB, even if we use volatile reads and
            // discard the data when a data race is detected. The proper solution would be to
            // do atomic reads and atomic writes, but we can't atomically read and write all
            // kinds of data since `AtomicU8` is not available on stable Rust yet.
            if let Ok(val) = lock.read_optimistic(|| ptr::read_volatile(src)) {
                val
            } else {
                // Grab a regular read lock so that writers don't starve this load.
                lock.read(|| ptr::read(src))
            }
        }
    }
}
pub unsafe fn atomic_load < T : Copy , L : FallbackLock > ( lock : & L , src : * mut Option < T > ) -> Option < T > { atomic ! { Option T a { a ( src as const as const ) mem transmute_copy ( a load ( Ordering Acquire ) ) } { // Try doing an optimistic read first. // We need a volatile read here because other threads might concurrently modify the // value. In theory, data races are *always* UB, even if we use volatile reads and // discard the data when a data race is detected. The proper solution would be to // do atomic reads and atomic writes, but we can't atomically read and write all // kinds of data since `AtomicU8` is not available on stable Rust yet. if let Ok ( val ) lock read_optimistic ( ptr read_volatile ( src ) ) { val } else { // Grab a regular read lock so that writers don't starve this load. lock read ( ptr read ( src ) ) } } } }
Atomically reads data from `src`.
Atomically reads data from ` src ` .
lock
&L
src
*mut Option<T>
lock
&L
src
*mut Option<T>