Sha256: 335b42278217a3020ec1419d070132f8f5a0ce832c504dc7806c42821848be83

Contents?: true

Size: 1.04 KB

Versions: 30

Compression:

Stored size: 1.04 KB

Contents

use super::Synced;

use crate::runtime::task;

use std::marker::PhantomData;

pub(crate) struct Pop<'a, T: 'static> {
    len: usize,
    synced: &'a mut Synced,
    _p: PhantomData<T>,
}

impl<'a, T: 'static> Pop<'a, T> {
    pub(super) fn new(len: usize, synced: &'a mut Synced) -> Pop<'a, T> {
        Pop {
            len,
            synced,
            _p: PhantomData,
        }
    }
}

impl<'a, T: 'static> Iterator for Pop<'a, T> {
    type Item = task::Notified<T>;

    fn next(&mut self) -> Option<Self::Item> {
        if self.len == 0 {
            return None;
        }

        let ret = self.synced.pop();

        // Should be `Some` when `len > 0`
        debug_assert!(ret.is_some());

        self.len -= 1;
        ret
    }

    fn size_hint(&self) -> (usize, Option<usize>) {
        (self.len, Some(self.len))
    }
}

impl<'a, T: 'static> ExactSizeIterator for Pop<'a, T> {
    fn len(&self) -> usize {
        self.len
    }
}

impl<'a, T: 'static> Drop for Pop<'a, T> {
    fn drop(&mut self) {
        for _ in self.by_ref() {}
    }
}

Version data entries

30 entries across 30 versions & 1 rubygems

Version Path
wasmtime-29.0.0 ./ext/cargo-vendor/tokio-1.43.0/src/runtime/scheduler/inject/pop.rs
wasmtime-28.0.0 ./ext/cargo-vendor/tokio-1.43.0/src/runtime/scheduler/inject/pop.rs
wasmtime-27.0.0 ./ext/cargo-vendor/tokio-1.41.1/src/runtime/scheduler/inject/pop.rs
wasmtime-26.0.0 ./ext/cargo-vendor/tokio-1.41.0/src/runtime/scheduler/inject/pop.rs
wasmtime-25.0.2 ./ext/cargo-vendor/tokio-1.40.0/src/runtime/scheduler/inject/pop.rs
wasmtime-25.0.1 ./ext/cargo-vendor/tokio-1.39.3/src/runtime/scheduler/inject/pop.rs
wasmtime-25.0.0 ./ext/cargo-vendor/tokio-1.39.3/src/runtime/scheduler/inject/pop.rs
wasmtime-24.0.0 ./ext/cargo-vendor/tokio-1.39.3/src/runtime/scheduler/inject/pop.rs
wasmtime-23.0.2 ./ext/cargo-vendor/tokio-1.36.0/src/runtime/scheduler/inject/pop.rs
wasmtime-22.0.0 ./ext/cargo-vendor/tokio-1.36.0/src/runtime/scheduler/inject/pop.rs
wasmtime-21.0.1 ./ext/cargo-vendor/tokio-1.36.0/src/runtime/scheduler/inject/pop.rs
wasmtime-20.0.2 ./ext/cargo-vendor/tokio-1.36.0/src/runtime/scheduler/inject/pop.rs
wasmtime-20.0.0 ./ext/cargo-vendor/tokio-1.36.0/src/runtime/scheduler/inject/pop.rs
wasmtime-18.0.3 ./ext/cargo-vendor/tokio-1.36.0/src/runtime/scheduler/inject/pop.rs
wasmtime-17.0.1 ./ext/cargo-vendor/tokio-1.35.1/src/runtime/scheduler/inject/pop.rs
wasmtime-17.0.0 ./ext/cargo-vendor/tokio-1.35.1/src/runtime/scheduler/inject/pop.rs
wasmtime-16.0.0 ./ext/cargo-vendor/tokio-1.35.1/src/runtime/scheduler/inject/pop.rs
wasmtime-15.0.1 ./ext/cargo-vendor/tokio-1.35.1/src/runtime/scheduler/inject/pop.rs
wasmtime-15.0.0 ./ext/cargo-vendor/tokio-1.35.1/src/runtime/scheduler/inject/pop.rs
wasmtime-14.0.4 ./ext/cargo-vendor/tokio-1.33.0/src/runtime/scheduler/inject/pop.rs