Skip to content

Feature: Provide getters of data and vtable pointer for RawWaker? #87021

Closed
@oxalica

Description

@oxalica

Docs of std::task::RawWaker:

It consists of a data pointer and a virtual function pointer table (vtable) that customizes the behavior of the RawWaker.

We said it consists of two pointer, but doesn't enforce its layout by repr, nor provide methods to get data and vtable pointer from a constructed RawWaker. So it impossible to destruct a RawWaker even with transmute, since the layout is unknown, which makdes it difficult to pass RawWaker or Waker across FFI boundary.

Note that Waker has repr(transparent) on it so it's able to transmute into a RawWaker. But it barely does anything since we can do nothing with a RawWaker. I'm confusing about why there is a repr(transparent) struct to an blackbox struct without any methods.

If it's intended to NOT stabilizing the layout of std::task::RawWaker. I think we should at least provide methods like fn data(&self) -> *mut () and fn vtable(&self) -> &'static RawWakerVTable to do the inverse of RawWaker::new, which can be used to destruct it to cross FFI boundary.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-async-awaitArea: Async & AwaitAsyncAwait-TriagedAsync-await issues that have been triaged during a working group meeting.C-feature-requestCategory: A feature request, i.e: not implemented / a PR.T-libs-apiRelevant to the library API team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions