Skip to content

compiles on linux but not windows #24442

Closed
@fuchsnj

Description

@fuchsnj
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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions