maycoon_core/tasks/
waker.rs

1use std::task::{RawWaker, RawWakerVTable, Waker};
2
3/// Creates a no-op waker.
4///
5/// Should only be used in certain cases.
6///
7/// Mostly used in [crate::tasks::task::Task::take].
8#[inline(always)]
9pub const fn noop_waker() -> Waker {
10    unsafe { Waker::from_raw(noop_raw_waker()) }
11}
12
13/// Create a no-op raw waker.
14#[inline(always)]
15const fn noop_raw_waker() -> RawWaker {
16    RawWaker::new(
17        std::ptr::null(),
18        &RawWakerVTable::new(clone, wake, wake_by_ref, drop),
19    )
20}
21
22/// No-op clone.
23#[inline(always)]
24const fn clone(_: *const ()) -> RawWaker {
25    noop_raw_waker()
26}
27
28/// No-op wake.
29#[inline(always)]
30const fn wake(_: *const ()) {}
31
32/// No-op wake-by-ref.
33#[inline(always)]
34const fn wake_by_ref(_: *const ()) {}
35
36/// No-op drop.
37#[inline(always)]
38const fn drop(_: *const ()) {}