diff options
| author | bors <bors@rust-lang.org> | 2014-05-07 05:16:48 -0700 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2014-05-07 05:16:48 -0700 |
| commit | ef6daf9935da103f1b915a5c9904794da79b0b60 (patch) | |
| tree | ad9695f06d85962039a8f90ac741726b345096aa /src/libstd/rt/thread.rs | |
| parent | 4a5d39001b1da84fe4be2996a2c7d894d5c248c6 (diff) | |
| parent | 090040bf4037a094e50b03d79e4baf5cd89c912b (diff) | |
| download | rust-ef6daf9935da103f1b915a5c9904794da79b0b60.tar.gz rust-ef6daf9935da103f1b915a5c9904794da79b0b60.zip | |
auto merge of #13958 : pcwalton/rust/detilde, r=pcwalton
for `~str`/`~[]`. Note that `~self` still remains, since I forgot to add support for `Box<self>` before the snapshot. r? @brson or @alexcrichton or whoever
Diffstat (limited to 'src/libstd/rt/thread.rs')
| -rw-r--r-- | src/libstd/rt/thread.rs | 19 |
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 |
