pub unsafe fn dequeue(&mut self) -> Option<*const u8> {
        enum DequeueResult {
            Empty,
            Success(*const u8),
            RetryInNextChunk,
        };

        let result = if self.state.read_at == self.state.write_at {
            DequeueResult::Empty
        } else {
            let offset = self.state.read_at - self.state.first_chunk_at;
            let chunk = &mut self.chunks[0];
            let entry_ptr = chunk.as_mut_ptr().offset(offset as isize);

            #[allow(clippy::cast_ptr_alignment)]
            match *(entry_ptr as *mut NextItemRef) {
                NextItemRef::NextChunk => {
                    self.state.first_chunk_at += chunk.len();
                    self.state.read_at = self.state.first_chunk_at;
                    DequeueResult::RetryInNextChunk
                }
                NextItemRef::SameChunk(total_size) => {
                    let payload_ptr = entry_ptr.offset(::std::mem::size_of::<NextItemRef>() as isize);
                    self.state.read_at += total_size;
                    self.state.len -= 1;
                    DequeueResult::Success(payload_ptr)
                }
            }
        };

        match result {
            DequeueResult::Empty => None,
            DequeueResult::Success(payload_ptr) => Some(payload_ptr),
            DequeueResult::RetryInNextChunk => {
                self.chunks_to_drop.push(self.chunks.remove(0));
                self.dequeue()
            }
        }
    }
/// Dequeue an item. Returns a pointer to the item in the queue, unless the queue is empty.
// TODO: return done_guard to mark as droppable
Dequeue an item. Returns a pointer to the item in the queue, unless the queue is empty.
TODO: return done_guard to mark as droppable
Dequeue an item . Returns a pointer to the item in the queue unless the queue is empty . TODO : return done_guard to mark as droppable
pub unsafe fn dequeue(&mut self) -> Option<*const u8> {
        enum DequeueResult {
            Empty,
            Success(*const u8),
            RetryInNextChunk,
        };
        let result = if self.state.read_at == self.state.write_at {
            DequeueResult::Empty
        } else {
            let offset = self.state.read_at - self.state.first_chunk_at;
            let chunk = &mut self.chunks[0];
            let entry_ptr = chunk.as_mut_ptr().offset(offset as isize);
            #[allow(clippy::cast_ptr_alignment)]
            match *(entry_ptr as *mut NextItemRef) {
                NextItemRef::NextChunk => {
                    self.state.first_chunk_at += chunk.len();
                    self.state.read_at = self.state.first_chunk_at;
                    DequeueResult::RetryInNextChunk
                }
                NextItemRef::SameChunk(total_size) => {
                    let payload_ptr = entry_ptr.offset(::std::mem::size_of::<NextItemRef>() as isize);
                    self.state.read_at += total_size;
                    self.state.len -= 1;
                    DequeueResult::Success(payload_ptr)
                }
            }
        };
        match result {
            DequeueResult::Empty => None,
            DequeueResult::Success(payload_ptr) => Some(payload_ptr),
            DequeueResult::RetryInNextChunk => {
                self.chunks_to_drop.push(self.chunks.remove(0));
                self.dequeue()
            }
        }
    }
pub unsafe fn dequeue ( & mut self ) -> Option < * const u8 > { enum DequeueResult { Empty , Success ( * const u8 ) , RetryInNextChunk , } ; let result = if self . state . read_at == self . state . write_at { DequeueResult :: Empty } else { let offset = self . state . read_at - self . state . first_chunk_at ; let chunk = & mut self . chunks [ 0 ] ; let entry_ptr = chunk . as_mut_ptr ( ) . offset ( offset as isize ) ; # [ allow ( clippy cast_ptr_alignment ) ] match * ( entry_ptr as * mut NextItemRef ) { NextItemRef :: NextChunk => { self . state . first_chunk_at += chunk . len ( ) ; self . state . read_at = self . state . first_chunk_at ; DequeueResult :: RetryInNextChunk } NextItemRef :: SameChunk ( total_size ) => { let payload_ptr = entry_ptr . offset ( :: std :: mem :: size_of :: < NextItemRef > ( ) as isize ) ; self . state . read_at += total_size ; self . state . len -= 1 ; DequeueResult :: Success ( payload_ptr ) } } } ; match result { DequeueResult :: Empty => None , DequeueResult :: Success ( payload_ptr ) => Some ( payload_ptr ) , DequeueResult :: RetryInNextChunk => { self . chunks_to_drop . push ( self . chunks . remove ( 0 ) ) ; self . dequeue ( ) } } }
Dequeue an item.
Dequeue an item .
&mut self
&mut self