struct ActualWaker {
data: Weak<Shared>,
id: Ti,
}
Expand description
Actual implementor of Wake
for use in a Waker
Futures (eg, channels from [futures
]) will use this to wake a task
when it should be polled.
This type must not be Cloned
with the Data
lock held.
Consequently, a Waker
mustn’t either.
Fields§
§data: Weak<Shared>
Executor state
The Waker mustn’t to hold a strong reference to the executor, since typically a task holds a future that holds a Waker, and the executor holds the task - so that would be a cycle.
id: Ti
Which task this is
Implementations§
Source§impl ActualWaker
impl ActualWaker
Source§impl ActualWaker
Using ActualWaker
in a RawWaker
impl ActualWaker
Using ActualWaker
in a RawWaker
We need to make a
Waker
(the safe, type-erased, waker, used by actual futures)
which contains an
ActualWaker
(our actual waker implementation, also safe).
std
offers Waker::from<Arc<impl Wake>>
.
But we want a bespoke Clone
implementation, so we don’t want to use Arc
.
So instead, we implement the RawWaker
API in terms of ActualWaker
.
We keep the ActualWaker
in a Box
, and actually clone
it (and the Box
).
SAFETY
- The data pointer is
Box::<ActualWaker>::into_raw()
- We share these when we clone
- No-one is allowed
&mut ActualWaker
unless there are no other clones - So we may make references
&ActualWaker
Sourcefn new_waker(self) -> Waker
fn new_waker(self) -> Waker
Wrap up an ActualWaker
as a type-erased Waker
for passing to futures etc.
Sourcefn raw_new(self) -> RawWaker
fn raw_new(self) -> RawWaker
Helper: wrap up an ActualWaker
as a RawWaker
.
Sourceunsafe fn raw_wake(self_: *const ())
unsafe fn raw_wake(self_: *const ())
Implementation of RawWakerVTable
’s wake
Sourceunsafe fn raw_wake_by_ref(self_: *const ())
unsafe fn raw_wake_by_ref(self_: *const ())
Implementation of RawWakerVTable
’s wake_ref_by
Sourceunsafe fn raw_drop(self_: *const ())
unsafe fn raw_drop(self_: *const ())
Implementation of RawWakerVTable
’s drop
Trait Implementations§
Source§impl Clone for ActualWaker
Track sleep locations via <Waker as Clone>
.
impl Clone for ActualWaker
Track sleep locations via <Waker as Clone>
.
See MockExecutor::debug_dump
for the explanation.
impl EnsureSyncSend for ActualWaker
Auto Trait Implementations§
impl Freeze for ActualWaker
impl RefUnwindSafe for ActualWaker
impl Send for ActualWaker
impl Sync for ActualWaker
impl Unpin for ActualWaker
impl UnwindSafe for ActualWaker
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more