executor: Add 'raw' api to wake tasks through raw pointers.

This commit is contained in:
Dario Nieuwenhuis 2021-01-21 00:59:09 +01:00
parent 28b5d8e9f4
commit 5b897b6605

View File

@ -259,3 +259,18 @@ pub(crate) unsafe fn register_timer(at: Instant, waker: &Waker) {
let expires_at = header.expires_at.get();
header.expires_at.set(min(expires_at, at));
}
pub mod raw {
use super::waker;
use core::ptr::NonNull;
use core::task::Waker;
pub fn task_from_waker(waker: &Waker) -> NonNull<()> {
unsafe { NonNull::new_unchecked(waker::task_from_waker(waker) as *mut ()) }
}
pub unsafe fn wake_task(task: NonNull<()>) {
let header = &*waker::task_from_ptr(task.as_ptr());
header.enqueue();
}
}