fn poll(&self, dst: &mut sys::Events) {
        // `until` is set with the first node that gets re-enqueued due to being
        // set to have level-triggered notifications. This prevents an infinite
        // loop where `Poll::poll` will keep dequeuing nodes it enqueues.
        let mut until = ptr::null_mut();

        'outer:
        while dst.len() < dst.capacity() {
            // Dequeue a node. If the queue is in an inconsistent state, then
            // stop polling. `Poll::poll` will be called again shortly and enter
            // a syscall, which should be enough to enable the other thread to
            // finish the queuing process.
            let ptr = match unsafe { self.inner.dequeue_node(until) } {
                Dequeue::Empty | Dequeue::Inconsistent => break,
                Dequeue::Data(ptr) => ptr,
            };

            let node = unsafe { &*ptr };

            // Read the node state with Acquire ordering. This allows reading
            // the token variables.
            let mut state = node.state.load(Acquire);
            let mut next;
            let mut readiness;
            let mut opt;

            loop {
                // Build up any changes to the readiness node's state and
                // attempt the CAS at the end
                next = state;

                // Given that the node was just read from the queue, the
                // `queued` flag should still be set.
                debug_assert!(state.is_queued());

                // The dropped flag means we need to release the node and
                // perform no further processing on it.
                if state.is_dropped() {
                    // Release the node and continue
                    release_node(ptr);
                    continue 'outer;
                }

                // Process the node
                readiness = state.effective_readiness();
                opt = state.poll_opt();

                if opt.is_edge() {
                    // Mark the node as dequeued
                    next.set_dequeued();

                    if opt.is_oneshot() && readiness.is_some() {
                        next.disarm();
                    }
                } else if readiness.is_none() {
                    next.set_dequeued();
                }

                // Ensure `token_read_pos` is set to `token_write_pos` so that
                // we read the most up to date token value.
                next.update_token_read_pos();

                if state == next {
                    break;
                }

                let actual = node.state.compare_and_swap(state, next, AcqRel);

                if actual == state {
                    break;
                }

                state = actual;
            }

            // If the queued flag is still set, then the node must be requeued.
            // This typically happens when using level-triggered notifications.
            if next.is_queued() {
                if until.is_null() {
                    // We never want to see the node again
                    until = ptr;
                }

                // Requeue the node
                self.inner.enqueue_node(node);
            }

            if readiness.is_some() {
                // Get the token
                let token = unsafe { token(node, next.token_read_pos()) };

                // Push the event
                dst.push_event(Event::new(readiness, token));
            }
        }
    }
/// Poll the queue for new events
Poll the queue for new events
Poll the queue for new events
fn poll(&self, dst: &mut sys::Events) {
        // `until` is set with the first node that gets re-enqueued due to being
        // set to have level-triggered notifications. This prevents an infinite
        // loop where `Poll::poll` will keep dequeuing nodes it enqueues.
        let mut until = ptr::null_mut();
        'outer:
        while dst.len() < dst.capacity() {
            // Dequeue a node. If the queue is in an inconsistent state, then
            // stop polling. `Poll::poll` will be called again shortly and enter
            // a syscall, which should be enough to enable the other thread to
            // finish the queuing process.
            let ptr = match unsafe { self.inner.dequeue_node(until) } {
                Dequeue::Empty | Dequeue::Inconsistent => break,
                Dequeue::Data(ptr) => ptr,
            };
            let node = unsafe { &*ptr };
            // Read the node state with Acquire ordering. This allows reading
            // the token variables.
            let mut state = node.state.load(Acquire);
            let mut next;
            let mut readiness;
            let mut opt;
            loop {
                // Build up any changes to the readiness node's state and
                // attempt the CAS at the end
                next = state;
                // Given that the node was just read from the queue, the
                // `queued` flag should still be set.
                debug_assert!(state.is_queued());
                // The dropped flag means we need to release the node and
                // perform no further processing on it.
                if state.is_dropped() {
                    // Release the node and continue
                    release_node(ptr);
                    continue 'outer;
                }
                // Process the node
                readiness = state.effective_readiness();
                opt = state.poll_opt();
                if opt.is_edge() {
                    // Mark the node as dequeued
                    next.set_dequeued();
                    if opt.is_oneshot() && readiness.is_some() {
                        next.disarm();
                    }
                } else if readiness.is_none() {
                    next.set_dequeued();
                }
                // Ensure `token_read_pos` is set to `token_write_pos` so that
                // we read the most up to date token value.
                next.update_token_read_pos();
                if state == next {
                    break;
                }
                let actual = node.state.compare_and_swap(state, next, AcqRel);
                if actual == state {
                    break;
                }
                state = actual;
            }
            // If the queued flag is still set, then the node must be requeued.
            // This typically happens when using level-triggered notifications.
            if next.is_queued() {
                if until.is_null() {
                    // We never want to see the node again
                    until = ptr;
                }
                // Requeue the node
                self.inner.enqueue_node(node);
            }
            if readiness.is_some() {
                // Get the token
                let token = unsafe { token(node, next.token_read_pos()) };
                // Push the event
                dst.push_event(Event::new(readiness, token));
            }
        }
    }
fn poll ( & self , dst : & mut sys :: Events ) { // `until` is set with the first node that gets re-enqueued due to being // set to have level-triggered notifications. This prevents an infinite // loop where `Poll::poll` will keep dequeuing nodes it enqueues. let mut until = ptr :: null_mut ( ) ; ' outer : while dst . len ( ) < dst . capacity ( ) { // Dequeue a node. If the queue is in an inconsistent state, then // stop polling. `Poll::poll` will be called again shortly and enter // a syscall, which should be enough to enable the other thread to // finish the queuing process. let ptr = match unsafe { self . inner . dequeue_node ( until ) } { Dequeue :: Empty | Dequeue :: Inconsistent => break , Dequeue :: Data ( ptr ) => ptr , } ; let node = unsafe { & * ptr } ; // Read the node state with Acquire ordering. This allows reading // the token variables. let mut state = node . state . load ( Acquire ) ; let mut next ; let mut readiness ; let mut opt ; loop { // Build up any changes to the readiness node's state and // attempt the CAS at the end next = state ; // Given that the node was just read from the queue, the // `queued` flag should still be set. debug_assert ! ( state is_queued ( ) ) ; // The dropped flag means we need to release the node and // perform no further processing on it. if state . is_dropped ( ) { // Release the node and continue release_node ( ptr ) ; continue ' outer ; } // Process the node readiness = state . effective_readiness ( ) ; opt = state . poll_opt ( ) ; if opt . is_edge ( ) { // Mark the node as dequeued next . set_dequeued ( ) ; if opt . is_oneshot ( ) && readiness . is_some ( ) { next . disarm ( ) ; } } else if readiness . is_none ( ) { next . set_dequeued ( ) ; } // Ensure `token_read_pos` is set to `token_write_pos` so that // we read the most up to date token value. next . update_token_read_pos ( ) ; if state == next { break ; } let actual = node . state . compare_and_swap ( state , next , AcqRel ) ; if actual == state { break ; } state = actual ; } // If the queued flag is still set, then the node must be requeued. // This typically happens when using level-triggered notifications. if next . is_queued ( ) { if until . is_null ( ) { // We never want to see the node again until = ptr ; } // Requeue the node self . inner . enqueue_node ( node ) ; } if readiness . is_some ( ) { // Get the token let token = unsafe { token ( node , next . token_read_pos ( ) ) } ; // Push the event dst . push_event ( Event :: new ( readiness , token ) ) ; } } }
Poll the queue for new events
Poll the queue for new events
&self
dst
&mut sys::Events