Add Thread::into_raw and Thread::from_raw functions by h33p · Pull Request #109794 · rust-lang/rust (original) (raw)

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 andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Conversation5 Commits1 Checks0 Files changed

Conversation

This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters

[ Show hidden characters]({{ revealButtonHref }})

h33p

Allows converting a Thread into a raw pointer for use in futures executors, FFI and other lower level code.

ACP: rust-lang/libs-team#200

I took the liberty to assign thread_pointer_conversion feature flag, but I'm not sure if the functions are the only place I need to add it.

Also I'm unsure whether from_raw needs #[must_use] or not.

@h33p

@rustbot

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @thomcc (or someone else) soon.

Please see the contribution instructions for more information. Namely, in order to ensure the minimum review times lag, PR authors and assigned reviewers should ensure that the review label (S-waiting-on-review and S-waiting-on-author) stays updated, invoking these commands when appropriate:

@rustbot rustbot added S-waiting-on-review

Status: Awaiting review from the assignee but also interested parties.

T-libs

Relevant to the library team, which will review and decide on the PR/issue.

labels

Mar 30, 2023

@rustbot

Hey! It looks like you've submitted a new PR for the library teams!

If this PR contains changes to any rust-lang/rust public library APIs then please comment with @rustbot label +T-libs-api -T-libs to tag it appropriately. If this PR contains changes to any unstable APIs please edit the PR description to add a link to the relevant API Change Proposal or create one if you haven't already. If you're unsure where your change falls no worries, just leave it as is and the reviewer will take a look and make a decision to forward on if necessary.

Examples of T-libs-api changes:

@h33p

@rustbot rustbot added T-libs-api

Relevant to the library API team, which will review and decide on the PR/issue.

and removed T-libs

Relevant to the library team, which will review and decide on the PR/issue.

labels

Mar 30, 2023

@h33p h33p mentioned this pull request

Mar 30, 2023

@rust-log-analyzer

The job mingw-check failed! Check out the build log: (web) (plain)

Click to see the possible cause of the failure (guessed by this bot)

........................................................................................  792/1132
.................................................................................iii....  880/1132
........................................................................................  968/1132
.............................................................................iiiiii..... 1056/1132
.......................F.F..................i...............................
failures:

---- src/thread/mod.rs - thread::Thread::from_raw (line 1346) stdout ----
error[E0658]: use of unstable library feature 'thread_pointer_conversion'
---
   |                                          ^^^^^^^^
   |
   = help: add `#![feature(thread_pointer_conversion)]` to the crate attributes to enable

error[E0277]: `*const ()` cannot be sent between threads safely
    |
    |
9   | let handle = thread::spawn(move || {
    |              ^^^^^^^^^^^^^ `*const ()` cannot be sent between threads safely
    |
    = help: within `(*const (), *const ())`, the trait `Send` is not implemented for `*const ()`
    = note: required because it appears within the type `(*const (), *const ())`
note: required by a bound in `spawn`
    |
680 |     T: Send + 'static,
    |        ^^^^ required by this bound in `spawn`

---
   |                        ^^^^^^^^^^^^^^^^
   |
   = help: add `#![feature(thread_pointer_conversion)]` to the crate attributes to enable

error[E0369]: binary operation `==` cannot be applied to type `Thread`
   |
   |
20 |     assert_ne!(main_thread, child_thread);
   |     |
   |     Thread
   |     Thread
   |
   |
   = note: this error originates in the macro `assert_ne` (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0369]: binary operation `==` cannot be applied to type `Thread`
   |
21 |     assert_eq!(main_thread, thread::current());
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |     |
---
    src/thread/mod.rs - thread::Thread::into_raw (line 1316)

test result: FAILED. 1112 passed; 2 failed; 18 ignored; 0 measured; 0 filtered out; finished in 11.61s

error: doctest failed, to rerun pass `-p std --doc`

@h33p

@h33p h33p mentioned this pull request

Mar 30, 2023

Labels

S-waiting-on-review

Status: Awaiting review from the assignee but also interested parties.

T-libs-api

Relevant to the library API team, which will review and decide on the PR/issue.