Stdlib unsafe wakers

Quoting: website/ at master · tokio-rs/website · GitHub

// The standard library provides low-level, unsafe  APIs for defining wakers.
// Instead of writing unsafe code, we will use the helpers provided by the
// `futures` crate to define a waker that is able to schedule our `Task`
// structure.
impl ArcWake for Task {
    fn wake_by_ref(arc_self: &Arc<Self>) {
        // Schedule the task for execution. The executor receives from the
        // channel and polls tasks.
        let _ = arc_self.executor.send(arc_self.clone());

Does anyone have code for this unsafe wakers? My goal here is to drop the Arc, along with the Send+Sync requirement of ArcWake. (Not for production use; just for learning purposes.)

Docs are probably referring to the RawWaker, which is essentially a pointer to some data plus four function pointers for the common operations.


I tried to write a minimal executor a couple of years ago with just std. I've since seen a few similar examples, but don't have links to them.

1 Like

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.