Struct futures_task::WakerRef
source · [−]pub struct WakerRef<'a> { /* private fields */ }
Expand description
A [Waker
] that is only valid for a given lifetime.
Note: this type implements Deref<Target = Waker>
,
so it can be used to get a &Waker
.
Implementations
sourceimpl<'a> WakerRef<'a>
impl<'a> WakerRef<'a>
sourcepub fn new_unowned(waker: ManuallyDrop<Waker>) -> Self
pub fn new_unowned(waker: ManuallyDrop<Waker>) -> Self
Create a new WakerRef
from a [Waker
] that must not be dropped.
Note: this if for rare cases where the caller created a [Waker
] in
an unsafe way (that will be valid only for a lifetime to be determined
by the caller), and the [Waker
] doesn’t need to or must not be
destroyed.
Methods from Deref<Target = Waker>
1.36.0pub fn wake_by_ref(&self)
pub fn wake_by_ref(&self)
Wake up the task associated with this Waker
without consuming the Waker
.
This is similar to wake()
, but may be slightly less efficient in
the case where an owned Waker
is available. This method should be preferred to
calling waker.clone().wake()
.
1.36.0pub fn will_wake(&self, other: &Waker) -> bool
pub fn will_wake(&self, other: &Waker) -> bool
Returns true
if this Waker
and another Waker
would awake the same task.
This function works on a best-effort basis, and may return false even
when the Waker
s would awaken the same task. However, if this function
returns true
, it is guaranteed that the Waker
s will awaken the same task.
This function is primarily used for optimization purposes.
pub fn as_raw(&self) -> &RawWaker
🔬This is a nightly-only experimental API. (waker_getters
)
pub fn as_raw(&self) -> &RawWaker
waker_getters
)Get a reference to the underlying [RawWaker
].