Skip to content
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

compiles on linux but not windows #24442

Closed
fuchsnj opened this issue Apr 15, 2015 · 0 comments · Fixed by #24447
Closed

compiles on linux but not windows #24442

fuchsnj opened this issue Apr 15, 2015 · 0 comments · Fixed by #24447

Comments

@fuchsnj
Copy link

fuchsnj commented Apr 15, 2015

use std::thread;
use std::thread::JoinGuard;
use std::collections::HashMap;
use std::sync::{Mutex,Arc};

fn main() {
    let join_guards:Arc<Mutex<HashMap<u64, JoinGuard<'static,()>>>> = Arc::new(Mutex::new(HashMap::new()));
    let join_guard = thread::scoped(move||{
        while join_guards.lock().unwrap().len() != 0{
            //...
        }
    });
}

The above code compiles fine using the latest nightly build on Ubuntu (rustc 1.0.0-nightly (e6a812402 2015-04-14) (built 2015-04-14))
but gets the following error on Windows 8 (same rustc version)

src\main.rs:11:19: 11:33 error: the trait `core::marker::Send` is not implemented for the type `*mut libc::types::common
::c95::c_void` [E0277]
src\main.rs:11  let join_guard = thread::scoped(move||{
                                 ^~~~~~~~~~~~~~
src\main.rs:11:19: 11:33 note: `*mut libc::types::common::c95::c_void` cannot be sent between threads safely
src\main.rs:11  let join_guard = thread::scoped(move||{
                                 ^~~~~~~~~~~~~~
error: aborting due to previous error
alexcrichton added a commit to alexcrichton/rust that referenced this issue Apr 15, 2015
Much of this code hasn't been updated in quite some time and this commit does a
small audit of the functionality:

* Implementation functions now centralize all functionality on a locally defined
  `Thread` type.
* The `detach` method has been removed in favor of a `Drop` implementation. This
  notably fixes leaking thread handles on Windows.
* The `Thread` structure is now appropriately annotated with `Send` and `Sync`
  automatically on Windows and in a custom fashion on Unix.
* The unsafety of creating a thread has been pushed out to the right boundaries
  now.

Closes rust-lang#24442
alexcrichton added a commit to alexcrichton/rust that referenced this issue Apr 15, 2015
Much of this code hasn't been updated in quite some time and this commit does a
small audit of the functionality:

* Implementation functions now centralize all functionality on a locally defined
  `Thread` type.
* The `detach` method has been removed in favor of a `Drop` implementation. This
  notably fixes leaking thread handles on Windows.
* The `Thread` structure is now appropriately annotated with `Send` and `Sync`
  automatically on Windows and in a custom fashion on Unix.
* The unsafety of creating a thread has been pushed out to the right boundaries
  now.

Closes rust-lang#24442
alexcrichton added a commit to alexcrichton/rust that referenced this issue Apr 22, 2015
Much of this code hasn't been updated in quite some time and this commit does a
small audit of the functionality:

* Implementation functions now centralize all functionality on a locally defined
  `Thread` type.
* The `detach` method has been removed in favor of a `Drop` implementation. This
  notably fixes leaking thread handles on Windows.
* The `Thread` structure is now appropriately annotated with `Send` and `Sync`
  automatically on Windows and in a custom fashion on Unix.
* The unsafety of creating a thread has been pushed out to the right boundaries
  now.

Closes rust-lang#24442
alexcrichton added a commit to alexcrichton/rust that referenced this issue Apr 22, 2015
Much of this code hasn't been updated in quite some time and this commit does a
small audit of the functionality:

* Implementation functions now centralize all functionality on a locally defined
  `Thread` type.
* The `detach` method has been removed in favor of a `Drop` implementation. This
  notably fixes leaking thread handles on Windows.
* The `Thread` structure is now appropriately annotated with `Send` and `Sync`
  automatically on Windows and in a custom fashion on Unix.
* The unsafety of creating a thread has been pushed out to the right boundaries
  now.

Closes rust-lang#24442
bors added a commit that referenced this issue Apr 22, 2015
Much of this code hasn't been updated in quite some time and this commit does a
small audit of the functionality:

* Implementation functions now centralize all functionality on a locally defined
  `Thread` type.
* The `detach` method has been removed in favor of a `Drop` implementation. This
  notably fixes leaking thread handles on Windows.
* The `Thread` structure is now appropriately annotated with `Send` and `Sync`
  automatically on Windows and in a custom fashion on Unix.
* The unsafety of creating a thread has been pushed out to the right boundaries
  now.

Closes #24442
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant