Sha256: b69a737bcba7cd27c660081c57c03b3672502e2c358beece0d4d8c9815e8af92

Contents?: true

Size: 966 Bytes

Versions: 30

Compression:

Stored size: 966 Bytes

Contents

#![cfg_attr(
    any(not(all(tokio_unstable, feature = "full")), target_family = "wasm"),
    allow(dead_code)
)]

use crate::runtime::task;

pub(crate) struct Synced {
    /// True if the queue is closed.
    pub(super) is_closed: bool,

    /// Linked-list head.
    pub(super) head: Option<task::RawTask>,

    /// Linked-list tail.
    pub(super) tail: Option<task::RawTask>,
}

unsafe impl Send for Synced {}
unsafe impl Sync for Synced {}

impl Synced {
    pub(super) fn pop<T: 'static>(&mut self) -> Option<task::Notified<T>> {
        let task = self.head?;

        self.head = unsafe { task.get_queue_next() };

        if self.head.is_none() {
            self.tail = None;
        }

        unsafe { task.set_queue_next(None) };

        // safety: a `Notified` is pushed into the queue and now it is popped!
        Some(unsafe { task::Notified::from_raw(task) })
    }

    pub(crate) fn is_empty(&self) -> bool {
        self.head.is_none()
    }
}

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/synced.rs
wasmtime-28.0.0 ./ext/cargo-vendor/tokio-1.43.0/src/runtime/scheduler/inject/synced.rs
wasmtime-27.0.0 ./ext/cargo-vendor/tokio-1.41.1/src/runtime/scheduler/inject/synced.rs
wasmtime-26.0.0 ./ext/cargo-vendor/tokio-1.41.0/src/runtime/scheduler/inject/synced.rs
wasmtime-25.0.2 ./ext/cargo-vendor/tokio-1.40.0/src/runtime/scheduler/inject/synced.rs
wasmtime-25.0.1 ./ext/cargo-vendor/tokio-1.39.3/src/runtime/scheduler/inject/synced.rs
wasmtime-25.0.0 ./ext/cargo-vendor/tokio-1.39.3/src/runtime/scheduler/inject/synced.rs
wasmtime-24.0.0 ./ext/cargo-vendor/tokio-1.39.3/src/runtime/scheduler/inject/synced.rs
wasmtime-23.0.2 ./ext/cargo-vendor/tokio-1.36.0/src/runtime/scheduler/inject/synced.rs
wasmtime-22.0.0 ./ext/cargo-vendor/tokio-1.36.0/src/runtime/scheduler/inject/synced.rs
wasmtime-21.0.1 ./ext/cargo-vendor/tokio-1.36.0/src/runtime/scheduler/inject/synced.rs
wasmtime-20.0.2 ./ext/cargo-vendor/tokio-1.36.0/src/runtime/scheduler/inject/synced.rs
wasmtime-20.0.0 ./ext/cargo-vendor/tokio-1.36.0/src/runtime/scheduler/inject/synced.rs
wasmtime-18.0.3 ./ext/cargo-vendor/tokio-1.36.0/src/runtime/scheduler/inject/synced.rs
wasmtime-17.0.1 ./ext/cargo-vendor/tokio-1.35.1/src/runtime/scheduler/inject/synced.rs
wasmtime-17.0.0 ./ext/cargo-vendor/tokio-1.35.1/src/runtime/scheduler/inject/synced.rs
wasmtime-16.0.0 ./ext/cargo-vendor/tokio-1.35.1/src/runtime/scheduler/inject/synced.rs
wasmtime-15.0.1 ./ext/cargo-vendor/tokio-1.35.1/src/runtime/scheduler/inject/synced.rs
wasmtime-15.0.0 ./ext/cargo-vendor/tokio-1.35.1/src/runtime/scheduler/inject/synced.rs
wasmtime-14.0.4 ./ext/cargo-vendor/tokio-1.33.0/src/runtime/scheduler/inject/synced.rs