pub fn send<F: FnOnce(*mut T, usize) -> usize>(&mut self, f: F) -> Result<Status, Error> {
        let cb = self.buf.load_count()?;
        let l = self.buf.length;

        let n = {
             let end = self.index + cmp::min(l - self.index, l - cb);
             let slice_start = unsafe { self.buf.data.offset(self.index as isize) };
             let slice_len = end - self.index;

             let n = if slice_len == 0 { 0 } else { f(slice_start, slice_len) };
             if n > slice_len { Err(Error::CallbackWroteTooMuch)? }
             assert!(n <= slice_len);
             n
        };

        let c = self.buf.count().fetch_add(n, Ordering::AcqRel);
        self.index = (self.index + n) % l;
        // dbg!("Send: cb = {}, c = {}, l = {}, n = {}", cb, c, l, n);
        Ok(Status {
            remaining: l - c - n,
            signal: c == 0 && n > 0
        })
    }
/// Lowest level "send" function
///
/// The closure will be called only if the buffer is not full, and needs to returns the number
/// of items written to the buffer.
///
/// The pointer sent to the closure is an "out" parameter to the first item, and the second
/// parameter is the number of items that can be written to the buffer
///
/// Since this is a ringbuffer, there might be more items to write even if you
/// completely fill up during the closure.
Lowest level "send" function
The closure will be called only if the buffer is not full, and needs to returns the number
of items written to the buffer.

The pointer sent to the closure is an "out" parameter to the first item, and the second
parameter is the number of items that can be written to the buffer

Since this is a ringbuffer, there might be more items to write even if you
completely fill up during the closure.
Lowest level " send " function The closure will be called only if the buffer is not full and needs to returns the number of items written to the buffer . The pointer sent to the closure is an " out " parameter to the first item and the second parameter is the number of items that can be written to the buffer Since this is a ringbuffer there might be more items to write even if you completely fill up during the closure .
pub fn send<F: FnOnce(*mut T, usize) -> usize>(&mut self, f: F) -> Result<Status, Error> {
        let cb = self.buf.load_count()?;
        let l = self.buf.length;
        let n = {
             let end = self.index + cmp::min(l - self.index, l - cb);
             let slice_start = unsafe { self.buf.data.offset(self.index as isize) };
             let slice_len = end - self.index;
             let n = if slice_len == 0 { 0 } else { f(slice_start, slice_len) };
             if n > slice_len { Err(Error::CallbackWroteTooMuch)? }
             assert!(n <= slice_len);
             n
        };
        let c = self.buf.count().fetch_add(n, Ordering::AcqRel);
        self.index = (self.index + n) % l;
        // dbg!("Send: cb = {}, c = {}, l = {}, n = {}", cb, c, l, n);
        Ok(Status {
            remaining: l - c - n,
            signal: c == 0 && n > 0
        })
    }
pub fn send < F : FnOnce ( * mut T , usize ) -> usize > ( & mut self , f : F ) -> Result < Status , Error > { let cb = self . buf . load_count ( ) ? ; let l = self . buf . length ; let n = { let end = self . index + cmp :: min ( l - self . index , l - cb ) ; let slice_start = unsafe { self . buf . data . offset ( self . index as isize ) } ; let slice_len = end - self . index ; let n = if slice_len == 0 { 0 } else { f ( slice_start , slice_len ) } ; if n > slice_len { Err ( Error :: CallbackWroteTooMuch ) ? } assert ! ( n slice_len ) ; n } ; let c = self . buf . count ( ) . fetch_add ( n , Ordering :: AcqRel ) ; self . index = ( self . index + n ) % l ; // dbg!("Send: cb = {}, c = {}, l = {}, n = {}", cb, c, l, n); Ok ( Status { remaining : l - c - n , signal : c == 0 && n > 0 } ) }
Lowest level "send" function
The closure will be called only if the buffer is not full, and needs to returns the number
of items written to the buffer.
Lowest level " send " function The closure will be called only if the buffer is not full and needs to returns the number of items written to the buffer .
&mut self
f
F
&mut self
f
F