Struct futures::executor::NotifyHandle
source · [−]pub struct NotifyHandle { /* private fields */ }
Expand description
A NotifyHandle
is the core value through which notifications are routed
in the futures
crate.
All instances of Task
will contain a NotifyHandle
handle internally.
This handle itself contains a trait object pointing to an instance of the
Notify
trait, allowing notifications to get routed through it.
The NotifyHandle
type internally does not codify any particular memory
management strategy. Internally it contains an instance of *mut UnsafeNotify
, and more details about that trait can be found on its own
documentation. Consequently, though, the one constructor of this type,
NotifyHandle::new
, is unsafe
to call. It is not recommended to call
this constructor directly.
If you’re working with the standard library then it’s recommended to
work with the Arc
type. If you have a struct, T
, which implements the
Notify
trait, then you can construct this with
NotifyHandle::from(t: Arc<T>)
. The coercion to UnsafeNotify
will
happen automatically and safely for you.
When working externally from the standard library it’s recommended to
provide a similar safe constructor for your custom type as opposed to
recommending an invocation of NotifyHandle::new
directly.
Implementations
sourceimpl NotifyHandle
impl NotifyHandle
sourcepub unsafe fn new(inner: *mut dyn UnsafeNotify) -> NotifyHandle
pub unsafe fn new(inner: *mut dyn UnsafeNotify) -> NotifyHandle
Constructs a new NotifyHandle
directly.
Note that most code will not need to call this. Implementers of the
UnsafeNotify
trait will typically provide a wrapper that calls this
but you otherwise shouldn’t call it directly.
If you’re working with the standard library then it’s recommended to
use the NotifyHandle::from
function instead which works with the safe
Arc
type and the safe Notify
trait.
Trait Implementations
sourceimpl Clone for NotifyHandle
impl Clone for NotifyHandle
sourceimpl Debug for NotifyHandle
impl Debug for NotifyHandle
sourceimpl Drop for NotifyHandle
impl Drop for NotifyHandle
sourceimpl<T: Notify> From<&'static T> for NotifyHandle
impl<T: Notify> From<&'static T> for NotifyHandle
sourcefn from(src: &'static T) -> NotifyHandle
fn from(src: &'static T) -> NotifyHandle
Performs the conversion.
sourceimpl<T> From<Arc<T>> for NotifyHandle where
T: Notify + 'static,
impl<T> From<Arc<T>> for NotifyHandle where
T: Notify + 'static,
sourcefn from(rc: Arc<T>) -> NotifyHandle
fn from(rc: Arc<T>) -> NotifyHandle
Performs the conversion.
impl Send for NotifyHandle
impl Sync for NotifyHandle
Auto Trait Implementations
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcepub fn borrow_mut(&mut self) -> &mut T
pub fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcepub fn to_owned(&self) -> T
pub fn to_owned(&self) -> T
Creates owned data from borrowed data, usually by cloning. Read more
sourcepub fn clone_into(&self, target: &mut T)
pub fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more