/// Create a new wrapping ring buffer. The ring buffer size is specified in bytes and must be a power of 2. 
/// bytes is the number of bytes of RingBuffer::vec
/// we will require additional 16 bytes to store the meta-data for this ring.
Create a new wrapping ring buffer. The ring buffer size is specified in bytes and must be a power of 2.
bytes is the number of bytes of RingBuffer::vec
we will require additional 16 bytes to store the meta-data for this ring.
Create a new wrapping ring buffer . The ring buffer size is specified in bytes and must be a power of 2 . bytes is the number of bytes of RingBuffer :: vec we will require additional 16 bytes to store the meta - data for this ring .
pub unsafe fn attach_in_heap(bytes: usize, queue_addr_u64: u64) -> Result<RingBuffer>{
        if bytes & (bytes - 1) != 0 {
            // We need pages to be a power of 2.
            return Err(InvalidRingSize(bytes).into());
        }
        let head_addr = queue_addr_u64 as (*mut u32);
        let address = head_addr as *mut u8;
        Ok(RingBuffer {
            head: SuperUsize{ my_usize: (address as *mut usize) },
            tail: SuperUsize{ my_usize: (address as *mut usize).offset(1) }, 
            size: SuperUsize{ my_usize: (address as *mut usize).offset(2) },
            mask: SuperUsize{ my_usize: (address as *mut usize).offset(3) },
            vec: SuperVec{ my_vec: (address as *mut usize).offset(4) as (*mut (*mut MBuf))},
        })
    }
pub unsafe fn attach_in_heap ( bytes : usize , queue_addr_u64 : u64 ) -> Result < RingBuffer > { if bytes & ( bytes - 1 ) != 0 { // We need pages to be a power of 2. return Err ( InvalidRingSize ( bytes ) . into ( ) ) ; } let head_addr = queue_addr_u64 as ( * mut u32 ) ; let address = head_addr as * mut u8 ; Ok ( RingBuffer { head : SuperUsize { my_usize : ( address as * mut usize ) } , tail : SuperUsize { my_usize : ( address as * mut usize ) . offset ( 1 ) } , size : SuperUsize { my_usize : ( address as * mut usize ) . offset ( 2 ) } , mask : SuperUsize { my_usize : ( address as * mut usize ) . offset ( 3 ) } , vec : SuperVec { my_vec : ( address as * mut usize ) . offset ( 4 ) as ( * mut ( * mut MBuf ) ) } , } ) }
Create a new wrapping ring buffer.
Create a new wrapping ring buffer .
bytes
usize
queue_addr_u64
u64