fn clear_write(config: &AtomicU32, write_buffer_idx: usize) {
        // the index of the buffer that was written to
        let write_buffer_idx = write_buffer_idx as u32;
        config
            .fetch_update(SeqCst, SeqCst, |x| {
                // decompose the current config
                let mut cfg: TripleConfig = x.into();

                // the list of state indicies in most recent to least recently
                // updated, ignoring the current update
                let states = [cfg.idx1, cfg.idx2, cfg.idx3];

                // remove the state that was most recently updates
                // so it can be re-inserted at the start
                let states: Vec<_> = states.iter().filter(|x| **x != write_buffer_idx).collect();

                // set the config to have the newly updated state first, while
                // maintaining the order of the other two states
                cfg.idx1 = write_buffer_idx;
                cfg.idx2 = *states[0];
                cfg.idx3 = *states[1];

                // set that no write lock is currently held
                cfg.write = 3;

                Some(cfg.into())
            })
            // fetch update should only return an error if the function
            // provided returns None, which cannot happen
            .expect("Clear write unreachable failure");
    }
/// Remove the write lock index.
/// Updates idx1/idx2/idx3 so that the new state is set as the most
/// recently updated
/// Safety: Before calling this function the mutex for the state being
/// written must be released so that nothing blocks on acquiring the mutex
Remove the write lock index.
Updates idx1/idx2/idx3 so that the new state is set as the most
recently updated
Safety: Before calling this function the mutex for the state being
written must be released so that nothing blocks on acquiring the mutex
Remove the write lock index . Updates idx1 / idx2 / idx3 so that the new state is set as the most recently updated Safety : Before calling this function the mutex for the state being written must be released so that nothing blocks on acquiring the mutex
fn clear_write(config: &AtomicU32, write_buffer_idx: usize) {
        // the index of the buffer that was written to
        let write_buffer_idx = write_buffer_idx as u32;
        config
            .fetch_update(SeqCst, SeqCst, |x| {
                // decompose the current config
                let mut cfg: TripleConfig = x.into();
                // the list of state indicies in most recent to least recently
                // updated, ignoring the current update
                let states = [cfg.idx1, cfg.idx2, cfg.idx3];
                // remove the state that was most recently updates
                // so it can be re-inserted at the start
                let states: Vec<_> = states.iter().filter(|x| **x != write_buffer_idx).collect();
                // set the config to have the newly updated state first, while
                // maintaining the order of the other two states
                cfg.idx1 = write_buffer_idx;
                cfg.idx2 = *states[0];
                cfg.idx3 = *states[1];
                // set that no write lock is currently held
                cfg.write = 3;
                Some(cfg.into())
            })
            // fetch update should only return an error if the function
            // provided returns None, which cannot happen
            .expect("Clear write unreachable failure");
    }
fn clear_write ( config : & AtomicU32 , write_buffer_idx : usize ) { // the index of the buffer that was written to let write_buffer_idx = write_buffer_idx as u32 ; config . fetch_update ( SeqCst , SeqCst , | x | { // decompose the current config let mut cfg : TripleConfig = x . into ( ) ; // the list of state indicies in most recent to least recently // updated, ignoring the current update let states = [ cfg . idx1 , cfg . idx2 , cfg . idx3 ] ; // remove the state that was most recently updates // so it can be re-inserted at the start let states : Vec < _ > = states . iter ( ) . filter ( | x | * * x != write_buffer_idx ) . collect ( ) ; // set the config to have the newly updated state first, while // maintaining the order of the other two states cfg . idx1 = write_buffer_idx ; cfg . idx2 = * states [ 0 ] ; cfg . idx3 = * states [ 1 ] ; // set that no write lock is currently held cfg . write = 3 ; Some ( cfg . into ( ) ) } ) // fetch update should only return an error if the function // provided returns None, which cannot happen . expect ( " " ) ; }
Remove the write lock index.
Remove the write lock index .
config
&AtomicU32
write_buffer_idx
usize
config
&AtomicU32
write_buffer_idx
usize