about summary refs log tree commit diff
path: root/src/libstd/sys/windows
diff options
context:
space:
mode:
authorAlex Crichton <alex@alexcrichton.com>2015-02-17 15:19:18 -0800
committerAlex Crichton <alex@alexcrichton.com>2015-02-17 17:27:44 -0800
commitd8450d69bbb7bb5c288fba01295551b78a5a8c03 (patch)
tree180b2e9d64e822c78f8ad38c3eb7f1501c17862d /src/libstd/sys/windows
parentc14cf4dc868a9468dcf0a106a84dcafd859707fc (diff)
parentd0de2b46e9bcca93971ef64d6ecdef872633f246 (diff)
downloadrust-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/windows')
-rw-r--r--src/libstd/sys/windows/thread.rs8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/libstd/sys/windows/thread.rs b/src/libstd/sys/windows/thread.rs
index a38dc9b2d34..d7f86e1842e 100644
--- a/src/libstd/sys/windows/thread.rs
+++ b/src/libstd/sys/windows/thread.rs
@@ -10,6 +10,7 @@
 
 use boxed::Box;
 use cmp;
+use io;
 use mem;
 use ptr;
 use libc;
@@ -42,7 +43,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 arg: *mut libc::c_void = mem::transmute(box p);
     // FIXME On UNIX, we guard against stack sizes that are too small but
     // that's because pthreads enforces that stacks are at least
@@ -60,9 +61,10 @@ pub unsafe fn create(stack: uint, p: Thunk) -> rust_thread {
     if ret as uint == 0 {
         // be sure to not leak the closure
         let _p: Box<Thunk> = mem::transmute(arg);
-        panic!("failed to spawn native thread: {:?}", ret);
+        Err(io::Error::last_os_error())
+    } else {
+        Ok(ret)
     }
-    return ret;
 }
 
 pub unsafe fn set_name(_name: &str) {