fn flush_buffer<F>(buffer: &Self, retain: &mut Option<F>, counter: &mut usize)
    where
        F: FnMut((usize, T)),
    {
        let size_of_obj = mem::size_of::<T>();
        let data_bound = buffer.head.load(Acquire);
        let mut slot_addr = buffer.lower_bound;
        debug_assert!(
            buffer.refs.load(Acquire) <= 2 || buffer.refs.load(Acquire) >= 256,
            "Reference counting check failed"
        );
        for _ in 0..data_bound {
            unsafe {
                let slot = intrinsics::atomic_load_relaxed(slot_addr as *const usize);
                if slot != EMPTY_SLOT && slot != SENTINEL_SLOT {
                    let mut rest = (slot, T::default());
                    if size_of_obj > 0 {
                        rest.1 = ptr::read((slot_addr + mem::size_of::<usize>()) as *const T);
                    }
                    if let Some(retain) = retain {
                        retain(rest);
                    }
                    *counter += 1;
                }
            }
            slot_addr += buffer.tuple_size;
        }
        buffer.head.store(0, Release);
    }
// only use when the buffer is about to be be dead
// this require reference checking
only use when the buffer is about to be be dead
this require reference checking
only use when the buffer is about to be be dead this require reference checking
fn flush_buffer<F>(buffer: &Self, retain: &mut Option<F>, counter: &mut usize)
    where
        F: FnMut((usize, T)),
    {
        let size_of_obj = mem::size_of::<T>();
        let data_bound = buffer.head.load(Acquire);
        let mut slot_addr = buffer.lower_bound;
        debug_assert!(
            buffer.refs.load(Acquire) <= 2 || buffer.refs.load(Acquire) >= 256,
            "Reference counting check failed"
        );
        for _ in 0..data_bound {
            unsafe {
                let slot = intrinsics::atomic_load_relaxed(slot_addr as *const usize);
                if slot != EMPTY_SLOT && slot != SENTINEL_SLOT {
                    let mut rest = (slot, T::default());
                    if size_of_obj > 0 {
                        rest.1 = ptr::read((slot_addr + mem::size_of::<usize>()) as *const T);
                    }
                    if let Some(retain) = retain {
                        retain(rest);
                    }
                    *counter += 1;
                }
            }
            slot_addr += buffer.tuple_size;
        }
        buffer.head.store(0, Release);
    }
fn flush_buffer < F > ( buffer : & Self , retain : & mut Option < F > , counter : & mut usize ) where F : FnMut ( ( usize , T ) ) , { let size_of_obj = mem :: size_of :: < T > ( ) ; let data_bound = buffer . head . load ( Acquire ) ; let mut slot_addr = buffer . lower_bound ; debug_assert ! ( buffer refs load ( Acquire ) 2 buffer refs load ( Acquire ) 256 " " ) ; for _ in 0 .. data_bound { unsafe { let slot = intrinsics :: atomic_load_relaxed ( slot_addr as * const usize ) ; if slot != EMPTY_SLOT && slot != SENTINEL_SLOT { let mut rest = ( slot , T :: default ( ) ) ; if size_of_obj > 0 { rest . 1 = ptr :: read ( ( slot_addr + mem :: size_of :: < usize > ( ) ) as * const T ) ; } if let Some ( retain ) = retain { retain ( rest ) ; } * counter += 1 ; } } slot_addr += buffer . tuple_size ; } buffer . head . store ( 0 , Release ) ; }
only use when the buffer is about to be be dead
this require reference checking
only use when the buffer is about to be be dead this require reference checking
buffer
&Self
retain
&mut Option<F>
counter
&mut usize
buffer
&Self
retain
&mut Option<F>
counter
&mut usize