/// Creates a [`Waker`] from an `Arc<impl ArcWake>`. /// /// The returned [`Waker`] will call /// [`ArcWake.wake()`](ArcWake::wake) if awoken. pubfn waker<W>(wake: Arc<W>) -> Waker where
W: ArcWake + 'static,
{ let ptr = Arc::into_raw(wake).cast::<()>();
// FIXME: panics on Arc::clone / refcount changes could wreak havoc on the // code here. We should guard against this by aborting.
#[allow(clippy::redundant_clone)] // The clone here isn't actually redundant. unsafefn increase_refcount<T: ArcWake + 'static>(data: *const ()) { // Retain Arc, but don't touch refcount by wrapping in ManuallyDrop let arc = mem::ManuallyDrop::new(unsafe { Arc::<T>::from_raw(data.cast::<T>()) }); // Now increase refcount, but don't drop new refcount either let _arc_clone: mem::ManuallyDrop<_> = arc.clone();
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.