Coverage Report

Created: 2024-09-08 06:35

/rust/registry/src/index.crates.io-6f17d22bba15001f/futures-task-0.3.21/src/arc_wake.rs
Line
Count
Source
1
use alloc::sync::Arc;
2
3
/// A way of waking up a specific task.
4
///
5
/// By implementing this trait, types that are expected to be wrapped in an `Arc`
6
/// can be converted into [`Waker`] objects.
7
/// Those Wakers can be used to signal executors that a task it owns
8
/// is ready to be `poll`ed again.
9
///
10
/// Currently, there are two ways to convert `ArcWake` into [`Waker`]:
11
///
12
/// * [`waker`](super::waker()) converts `Arc<impl ArcWake>` into [`Waker`].
13
/// * [`waker_ref`](super::waker_ref()) converts `&Arc<impl ArcWake>` into [`WakerRef`] that
14
///   provides access to a [`&Waker`][`Waker`].
15
///
16
/// [`Waker`]: std::task::Waker
17
/// [`WakerRef`]: super::WakerRef
18
// Note: Send + Sync required because `Arc<T>` doesn't automatically imply
19
// those bounds, but `Waker` implements them.
20
pub trait ArcWake: Send + Sync {
21
    /// Indicates that the associated task is ready to make progress and should
22
    /// be `poll`ed.
23
    ///
24
    /// This function can be called from an arbitrary thread, including threads which
25
    /// did not create the `ArcWake` based [`Waker`].
26
    ///
27
    /// Executors generally maintain a queue of "ready" tasks; `wake` should place
28
    /// the associated task onto this queue.
29
    ///
30
    /// [`Waker`]: std::task::Waker
31
184
    fn wake(self: Arc<Self>) {
32
184
        Self::wake_by_ref(&self)
33
184
    }
Unexecuted instantiation: <futures_util::stream::futures_unordered::task::Task<core::pin::Pin<alloc::boxed::Box<dyn core::future::future::Future<Output = ()> + core::marker::Send>>> as futures_task::arc_wake::ArcWake>::wake
Unexecuted instantiation: <futures_util::stream::futures_unordered::task::Task<futures_task::future_obj::LocalFutureObj<()>> as futures_task::arc_wake::ArcWake>::wake
Unexecuted instantiation: <futures_executor::local_pool::ThreadNotify as futures_task::arc_wake::ArcWake>::wake
Unexecuted instantiation: <futures_util::stream::stream::flatten_unordered::InnerWaker as futures_task::arc_wake::ArcWake>::wake
Unexecuted instantiation: <_ as futures_task::arc_wake::ArcWake>::wake
<futures_util::stream::futures_unordered::task::Task<futures_util::future::future::remote_handle::Remote<devices::virtio::block::asynchronous::handle_queue::{closure#0}>> as futures_task::arc_wake::ArcWake>::wake
Line
Count
Source
31
184
    fn wake(self: Arc<Self>) {
32
184
        Self::wake_by_ref(&self)
33
184
    }
Unexecuted instantiation: <futures_util::stream::futures_unordered::task::Task<devices::virtio::scsi::device::process_one_chain::{closure#0}> as futures_task::arc_wake::ArcWake>::wake
Unexecuted instantiation: <futures_util::stream::futures_unordered::task::Task<devices::virtio::block::asynchronous::process_one_chain::{closure#0}> as futures_task::arc_wake::ArcWake>::wake
Unexecuted instantiation: <cros_async::blocking::sys::linux::block_on::Waker as futures_task::arc_wake::ArcWake>::wake
34
35
    /// Indicates that the associated task is ready to make progress and should
36
    /// be `poll`ed.
37
    ///
38
    /// This function can be called from an arbitrary thread, including threads which
39
    /// did not create the `ArcWake` based [`Waker`].
40
    ///
41
    /// Executors generally maintain a queue of "ready" tasks; `wake_by_ref` should place
42
    /// the associated task onto this queue.
43
    ///
44
    /// This function is similar to [`wake`](ArcWake::wake), but must not consume the provided data
45
    /// pointer.
46
    ///
47
    /// [`Waker`]: std::task::Waker
48
    fn wake_by_ref(arc_self: &Arc<Self>);
49
}