about summary refs log tree commit diff
path: root/src/libstd/rt/thread.rs
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2014-03-27 14:32:02 -0700
committerbors <bors@rust-lang.org>2014-03-27 14:32:02 -0700
commit13dafa09f1a80b8b50f41cab42ac2bfd24dfa6b9 (patch)
treeb9e7df5a742c922c22c5796969b4266850d6ce7e /src/libstd/rt/thread.rs
parent8eaada5d3922e5e39c402493a37c384699ef1756 (diff)
parent8d0be731f543837251ea10a77499725f91d02560 (diff)
downloadrust-13dafa09f1a80b8b50f41cab42ac2bfd24dfa6b9.tar.gz
rust-13dafa09f1a80b8b50f41cab42ac2bfd24dfa6b9.zip
auto merge of #13050 : alexcrichton/rust/no-send-default, r=huonw
See #10296 for the rationale, and commits for the implementation.
Diffstat (limited to 'src/libstd/rt/thread.rs')
-rw-r--r--src/libstd/rt/thread.rs16
1 files changed, 9 insertions, 7 deletions
diff --git a/src/libstd/rt/thread.rs b/src/libstd/rt/thread.rs
index 0cbd67557de..7c4bd895469 100644
--- a/src/libstd/rt/thread.rs
+++ b/src/libstd/rt/thread.rs
@@ -68,13 +68,13 @@ impl Thread<()> {
     /// to finish executing. This means that even if `join` is not explicitly
     /// called, when the `Thread` falls out of scope its destructor will block
     /// waiting for the OS thread.
-    pub fn start<T: Send>(main: proc() -> T) -> Thread<T> {
+    pub fn start<T: Send>(main: proc:Send() -> T) -> Thread<T> {
         Thread::start_stack(DEFAULT_STACK_SIZE, main)
     }
 
     /// Performs the same functionality as `start`, but specifies an explicit
     /// stack size for the new thread.
-    pub fn start_stack<T: Send>(stack: uint, main: proc() -> T) -> Thread<T> {
+    pub fn start_stack<T: Send>(stack: uint, main: proc:Send() -> T) -> Thread<T> {
 
         // We need the address of the packet to fill in to be stable so when
         // `main` fills it in it's still valid, so allocate an extra ~ box to do
@@ -83,7 +83,7 @@ impl Thread<()> {
         let packet2: *mut Option<T> = unsafe {
             *cast::transmute::<&~Option<T>, **mut Option<T>>(&packet)
         };
-        let main: proc() = proc() unsafe { *packet2 = Some(main()); };
+        let main = proc() unsafe { *packet2 = Some(main()); };
         let native = unsafe { imp::create(stack, ~main) };
 
         Thread {
@@ -99,13 +99,13 @@ impl Thread<()> {
     /// This corresponds to creating threads in the 'detached' state on unix
     /// systems. Note that platforms may not keep the main program alive even if
     /// there are detached thread still running around.
-    pub fn spawn(main: proc()) {
+    pub fn spawn(main: proc:Send()) {
         Thread::spawn_stack(DEFAULT_STACK_SIZE, main)
     }
 
     /// Performs the same functionality as `spawn`, but explicitly specifies a
     /// stack size for the new thread.
-    pub fn spawn_stack(stack: uint, main: proc()) {
+    pub fn spawn_stack(stack: uint, main: proc:Send()) {
         unsafe {
             let handle = imp::create(stack, ~main);
             imp::detach(handle);
@@ -146,6 +146,7 @@ impl<T: Send> Drop for Thread<T> {
 mod imp {
     use cast;
     use cmp;
+    use kinds::Send;
     use libc;
     use libc::types::os::arch::extra::{LPSECURITY_ATTRIBUTES, SIZE_T, BOOL,
                                        LPVOID, DWORD, LPDWORD, HANDLE};
@@ -155,7 +156,7 @@ mod imp {
     pub type rust_thread = HANDLE;
     pub type rust_thread_return = DWORD;
 
-    pub unsafe fn create(stack: uint, p: ~proc()) -> rust_thread {
+    pub unsafe fn create(stack: uint, p: ~proc:Send()) -> rust_thread {
         let arg: *mut libc::c_void = cast::transmute(p);
         // FIXME On UNIX, we guard against stack sizes that are too small but
         // that's because pthreads enforces that stacks are at least
@@ -203,6 +204,7 @@ mod imp {
 mod imp {
     use cast;
     use cmp;
+    use kinds::Send;
     use libc::consts::os::posix01::{PTHREAD_CREATE_JOINABLE, PTHREAD_STACK_MIN};
     use libc;
     use mem;
@@ -213,7 +215,7 @@ mod imp {
     pub type rust_thread = libc::pthread_t;
     pub type rust_thread_return = *u8;
 
-    pub unsafe fn create(stack: uint, p: ~proc()) -> rust_thread {
+    pub unsafe fn create(stack: uint, p: ~proc:Send()) -> rust_thread {
         let mut native: libc::pthread_t = mem::uninit();
         let mut attr: libc::pthread_attr_t = mem::uninit();
         assert_eq!(pthread_attr_init(&mut attr), 0);