diff options
| author | Alex Crichton <alex@alexcrichton.com> | 2015-02-17 15:19:18 -0800 |
|---|---|---|
| committer | Alex Crichton <alex@alexcrichton.com> | 2015-02-17 17:27:44 -0800 |
| commit | d8450d69bbb7bb5c288fba01295551b78a5a8c03 (patch) | |
| tree | 180b2e9d64e822c78f8ad38c3eb7f1501c17862d /src/libstd/sys/unix | |
| parent | c14cf4dc868a9468dcf0a106a84dcafd859707fc (diff) | |
| parent | d0de2b46e9bcca93971ef64d6ecdef872633f246 (diff) | |
| download | rust-d8450d69bbb7bb5c288fba01295551b78a5a8c03.tar.gz rust-d8450d69bbb7bb5c288fba01295551b78a5a8c03.zip | |
rollup merge of #22435: aturon/final-stab-thread
Conflicts: src/test/bench/rt-messaging-ping-pong.rs src/test/bench/rt-parfib.rs src/test/bench/task-perf-spawnalot.rs
Diffstat (limited to 'src/libstd/sys/unix')
| -rw-r--r-- | src/libstd/sys/unix/thread.rs | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/src/libstd/sys/unix/thread.rs b/src/libstd/sys/unix/thread.rs index 6f030ee91fe..82c52471d10 100644 --- a/src/libstd/sys/unix/thread.rs +++ b/src/libstd/sys/unix/thread.rs @@ -10,6 +10,7 @@ use core::prelude::*; +use io; use boxed::Box; use cmp; use mem; @@ -191,7 +192,7 @@ pub mod guard { } } -pub unsafe fn create(stack: uint, p: Thunk) -> rust_thread { +pub unsafe fn create(stack: uint, p: Thunk) -> io::Result<rust_thread> { let mut native: libc::pthread_t = mem::zeroed(); let mut attr: libc::pthread_attr_t = mem::zeroed(); assert_eq!(pthread_attr_init(&mut attr), 0); @@ -226,9 +227,10 @@ pub unsafe fn create(stack: uint, p: Thunk) -> rust_thread { if ret != 0 { // be sure to not leak the closure let _p: Box<Box<FnOnce()+Send>> = mem::transmute(arg); - panic!("failed to spawn native thread: {}", ret); + Err(io::Error::from_os_error(ret)) + } else { + Ok(native) } - native } #[cfg(any(target_os = "linux", target_os = "android"))] |
