/// `Arc` type and the safe `Wake` trait.
#[inline]
pub unsafe fn new(inner: NonNull<dyn UnsafeWake>) -> Self {
- Waker { inner: inner }
+ Waker { inner }
}
/// Wake up the task associated with this `Waker`.
/// on the current thread.
#[inline]
pub unsafe fn new(inner: NonNull<dyn UnsafeWake>) -> Self {
- LocalWaker { inner: inner }
+ LocalWaker { inner }
+ }
+
+ /// Converts this `LocalWaker` into a `Waker`.
+ ///
+ /// `Waker` is nearly identical to `LocalWaker`, but is threadsafe
+ /// (implements `Send` and `Sync`).
+ #[inline]
+ pub fn into_waker(self) -> Waker {
+ self.into()
}
/// Wake up the task associated with this `LocalWaker`.
impl From<LocalWaker> for Waker {
#[inline]
fn from(local_waker: LocalWaker) -> Self {
- Waker { inner: local_waker.inner }
+ let inner = local_waker.inner;
+ mem::forget(local_waker);
+ Waker { inner }
}
}