pub fn update_extremum<F>(&mut self, ptr: ValuePtr, extremum: usize, f: F) -> Result<(), HashStoreError>
        where F: Fn(Vec<u8>) -> bool
    {
        // Compare-and-swap loop
        loop {
            let current_ptr = self.extrema[extremum].load(atomic::Ordering::Acquire);

            if current_ptr != 0 {
                let current_value = self.get_by_ptr(current_ptr)?;
                if !f(current_value) {
                    return Ok(());
                }
            }

            let swap_ptr = self.extrema[extremum].compare_and_swap(current_ptr, ptr, atomic::Ordering::Release);

            if swap_ptr == current_ptr {
                return Ok(());
            }
        }
    }
/// Updates a 0-4 numbered extremum
///
/// The comparison function will be called with the current extremum value.
/// If it returns true, the extremum will be set to ptr.
///
/// The function may be called multiple times to resolvre concurrent updates in
/// the compare-and-swap loop
Updates a 0-4 numbered extremum
The comparison function will be called with the current extremum value.
If it returns true, the extremum will be set to ptr.

The function may be called multiple times to resolvre concurrent updates in
the compare-and-swap loop
Updates a 0 - 4 numbered extremum The comparison function will be called with the current extremum value . If it returns true the extremum will be set to ptr . The function may be called multiple times to resolvre concurrent updates in the compare - and - swap loop
pub fn update_extremum<F>(&mut self, ptr: ValuePtr, extremum: usize, f: F) -> Result<(), HashStoreError>
        where F: Fn(Vec<u8>) -> bool
    {
        // Compare-and-swap loop
        loop {
            let current_ptr = self.extrema[extremum].load(atomic::Ordering::Acquire);
            if current_ptr != 0 {
                let current_value = self.get_by_ptr(current_ptr)?;
                if !f(current_value) {
                    return Ok(());
                }
            }
            let swap_ptr = self.extrema[extremum].compare_and_swap(current_ptr, ptr, atomic::Ordering::Release);
            if swap_ptr == current_ptr {
                return Ok(());
            }
        }
    }
pub fn update_extremum < F > ( & mut self , ptr : ValuePtr , extremum : usize , f : F ) -> Result < ( ) , HashStoreError > where F : Fn ( Vec < u8 > ) -> bool { // Compare-and-swap loop loop { let current_ptr = self . extrema [ extremum ] . load ( atomic :: Ordering :: Acquire ) ; if current_ptr != 0 { let current_value = self . get_by_ptr ( current_ptr ) ? ; if ! f ( current_value ) { return Ok ( ( ) ) ; } } let swap_ptr = self . extrema [ extremum ] . compare_and_swap ( current_ptr , ptr , atomic :: Ordering :: Release ) ; if swap_ptr == current_ptr { return Ok ( ( ) ) ; } } }
Updates a 0-4 numbered extremum
The comparison function will be called with the current extremum value.
Updates a 0 - 4 numbered extremum The comparison function will be called with the current extremum value .
&mut self
ptr
ValuePtr
extremum
usize
f
F
&mut self
ptr
ValuePtr
extremum
usize
f
F