about summary refs log tree commit diff
path: root/src/libstd/rt/thread.rs
diff options
context:
space:
mode:
authorPatrick Walton <pcwalton@mimiga.net>2014-05-05 18:56:44 -0700
committerPatrick Walton <pcwalton@mimiga.net>2014-05-06 23:12:54 -0700
commit090040bf4037a094e50b03d79e4baf5cd89c912b (patch)
tree27fa91d623889d59260d3db167abdfa8c4288849 /src/libstd/rt/thread.rs
parent24f6f26e633e50b5b59f9d0f6cca0b1e49e215d9 (diff)
downloadrust-090040bf4037a094e50b03d79e4baf5cd89c912b.tar.gz
rust-090040bf4037a094e50b03d79e4baf5cd89c912b.zip
librustc: Remove `~EXPR`, `~TYPE`, and `~PAT` from the language, except
for `~str`/`~[]`.

Note that `~self` still remains, since I forgot to add support for
`Box<self>` before the snapshot.

How to update your code:

* Instead of `~EXPR`, you should write `box EXPR`.

* Instead of `~TYPE`, you should write `Box<Type>`.

* Instead of `~PATTERN`, you should write `box PATTERN`.

[breaking-change]
Diffstat (limited to 'src/libstd/rt/thread.rs')
-rw-r--r--src/libstd/rt/thread.rs19
1 files changed, 11 insertions, 8 deletions
diff --git a/src/libstd/rt/thread.rs b/src/libstd/rt/thread.rs
index a836958279b..bc9a0b3460a 100644
--- a/src/libstd/rt/thread.rs
+++ b/src/libstd/rt/thread.rs
@@ -22,6 +22,7 @@ use kinds::Send;
 use libc;
 use ops::Drop;
 use option::{Option, Some, None};
+use owned::Box;
 use uint;
 
 type StartFn = extern "C" fn(*libc::c_void) -> imp::rust_thread_return;
@@ -31,7 +32,7 @@ type StartFn = extern "C" fn(*libc::c_void) -> imp::rust_thread_return;
 pub struct Thread<T> {
     native: imp::rust_thread,
     joined: bool,
-    packet: ~Option<T>,
+    packet: Box<Option<T>>,
 }
 
 static DEFAULT_STACK_SIZE: uint = 1024 * 1024;
@@ -45,7 +46,7 @@ extern fn thread_start(main: *libc::c_void) -> imp::rust_thread_return {
     use rt::stack;
     unsafe {
         stack::record_stack_bounds(0, uint::MAX);
-        let f: ~proc() = cast::transmute(main);
+        let f: Box<proc()> = cast::transmute(main);
         (*f)();
         cast::transmute(0 as imp::rust_thread_return)
     }
@@ -78,11 +79,11 @@ impl Thread<()> {
     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
+        // `main` fills it in it's still valid, so allocate an extra box to do
         // so.
         let packet = box None;
         let packet2: *mut Option<T> = unsafe {
-            *cast::transmute::<&~Option<T>, **mut Option<T>>(&packet)
+            *cast::transmute::<&Box<Option<T>>, **mut Option<T>>(&packet)
         };
         let main = proc() unsafe { *packet2 = Some(main()); };
         let native = unsafe { imp::create(stack, box main) };
@@ -152,13 +153,14 @@ mod imp {
     use libc::types::os::arch::extra::{LPSECURITY_ATTRIBUTES, SIZE_T, BOOL,
                                        LPVOID, DWORD, LPDWORD, HANDLE};
     use os;
+    use owned::Box;
     use ptr;
     use rt::stack::RED_ZONE;
 
     pub type rust_thread = HANDLE;
     pub type rust_thread_return = DWORD;
 
-    pub unsafe fn create(stack: uint, p: ~proc():Send) -> rust_thread {
+    pub unsafe fn create(stack: uint, p: Box<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
@@ -175,7 +177,7 @@ mod imp {
 
         if ret as uint == 0 {
             // be sure to not leak the closure
-            let _p: ~proc():Send = cast::transmute(arg);
+            let _p: Box<proc():Send> = cast::transmute(arg);
             fail!("failed to spawn native thread: {}", os::last_os_error());
         }
         return ret;
@@ -218,13 +220,14 @@ mod imp {
     use libc;
     use mem;
     use os;
+    use owned::Box;
     use ptr;
     use rt::stack::RED_ZONE;
 
     pub type rust_thread = libc::pthread_t;
     pub type rust_thread_return = *u8;
 
-    pub unsafe fn create(stack: uint, p: ~proc():Send) -> rust_thread {
+    pub unsafe fn create(stack: uint, p: Box<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);
@@ -257,7 +260,7 @@ mod imp {
 
         if ret != 0 {
             // be sure to not leak the closure
-            let _p: ~proc():Send = cast::transmute(arg);
+            let _p: Box<proc():Send> = cast::transmute(arg);
             fail!("failed to spawn native thread: {}", os::last_os_error());
         }
         native