-
Notifications
You must be signed in to change notification settings - Fork 19
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ACP: add Thread::into_raw
and Thread::from_raw
#200
Labels
ACP-accepted
API Change Proposal is accepted (seconded with no objections)
api-change-proposal
A proposal to add or alter unstable APIs in the standard libraries
T-libs-api
Comments
h33p
added
api-change-proposal
A proposal to add or alter unstable APIs in the standard libraries
T-libs-api
labels
Mar 30, 2023
Just for reference: this has already been proposed, with the same API: rust-lang/rust#97524 |
Oh, my bad! Appears that I forgot to check for the most basic of things 🙃 |
Not to worry, it was quite buried. I just had a déjà vu. Anyway, it's probably best that this now gets a proper ACP... |
This was referenced Mar 30, 2023
We reviewed this (long-delayed) ACP in today's @rust-lang/libs-api meeting, and approved it. Thank you! |
joshtriplett
added
the
ACP-accepted
API Change Proposal is accepted (seconded with no objections)
label
Aug 20, 2024
tgross35
added a commit
to tgross35/rust
that referenced
this issue
Aug 21, 2024
Add `Thread::{into_raw, from_raw}` Public API: ```rust #![unstable(feature = "thread_raw", issue = "97523")] impl Thread { pub fn into_raw(self) -> *const (); pub unsafe fn from_raw(ptr: *const ()) -> Thread; } ``` ACP: rust-lang/libs-team#200
tgross35
added a commit
to tgross35/rust
that referenced
this issue
Aug 21, 2024
Add `Thread::{into_raw, from_raw}` Public API: ```rust #![unstable(feature = "thread_raw", issue = "97523")] impl Thread { pub fn into_raw(self) -> *const (); pub unsafe fn from_raw(ptr: *const ()) -> Thread; } ``` ACP: rust-lang/libs-team#200
4 tasks
workingjubilee
added a commit
to workingjubilee/rustc
that referenced
this issue
Sep 18, 2024
Add `Thread::{into_raw, from_raw}` Public API: ```rust #![unstable(feature = "thread_raw", issue = "97523")] impl Thread { pub fn into_raw(self) -> *const (); pub unsafe fn from_raw(ptr: *const ()) -> Thread; } ``` ACP: rust-lang/libs-team#200
workingjubilee
added a commit
to workingjubilee/rustc
that referenced
this issue
Sep 18, 2024
Add `Thread::{into_raw, from_raw}` Public API: ```rust #![unstable(feature = "thread_raw", issue = "97523")] impl Thread { pub fn into_raw(self) -> *const (); pub unsafe fn from_raw(ptr: *const ()) -> Thread; } ``` ACP: rust-lang/libs-team#200
rust-timer
added a commit
to rust-lang-ci/rust
that referenced
this issue
Sep 19, 2024
Rollup merge of rust-lang#97524 - ibraheemdev:thread-raw, r=ibraheemdev Add `Thread::{into_raw, from_raw}` Public API: ```rust #![unstable(feature = "thread_raw", issue = "97523")] impl Thread { pub fn into_raw(self) -> *const (); pub unsafe fn from_raw(ptr: *const ()) -> Thread; } ``` ACP: rust-lang/libs-team#200
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
ACP-accepted
API Change Proposal is accepted (seconded with no objections)
api-change-proposal
A proposal to add or alter unstable APIs in the standard libraries
T-libs-api
Proposal
Problem statement
It should be possible to convert a
Thread
from/to a raw pointer for passing thread handles across API boundaries in an opaque manner.Motivation, use-cases
Primary use case would be optimizing small futures executors.
pollster
- a minimalistic futures executor with over 1 million downloads would be a direct beneficiary of this. Currently,pollster
needs to heap allocate a signal on every future being executed. Alternative would be to use athread_local!
store of static signals/thread handles, but why bother, when aThread
is already that?As of today,
Thread
is merely a newtype around opaque Arc, and I was able to abuse this knowledge to remove heap allocations from pollster and speed it up by up to 2x (zesterer/pollster#19). Thus, it would be trivial to add methods to convert the thread handle into a raw pointer, and go the other way around.Additional use cases would be passing thread handles across FFI-boundary, which would enable better interoperability with other languages and dynamically loaded Rust libraries.
Solution sketches
We would add these functions to
Thread
implementation:Links and related work
Original PR to
pollster
: zesterer/pollster#14Prior implementation of this ACP: rust-lang/rust#97524
Implementation of this ACP (I closed it as duplicate): rust-lang/rust#109794
The text was updated successfully, but these errors were encountered: