From ddf179977e1e5565bbc48fdd1251356fc857336c Mon Sep 17 00:00:00 2001 From: Brian Anderson Date: Wed, 14 May 2014 01:13:29 -0700 Subject: [PATCH 1/3] std: Remove run_in_bare_thread --- src/libgreen/sched.rs | 6 ++-- src/librustuv/lib.rs | 6 ++-- src/librustuv/uvio.rs | 6 ++-- src/libstd/rt/local.rs | 22 +++++++------- src/libstd/unstable/mod.rs | 31 -------------------- src/test/run-pass/foreign-call-no-runtime.rs | 6 ++-- 6 files changed, 23 insertions(+), 54 deletions(-) diff --git a/src/libgreen/sched.rs b/src/libgreen/sched.rs index 8c294fa2928f0..5bc96dd6e8ee1 100644 --- a/src/libgreen/sched.rs +++ b/src/libgreen/sched.rs @@ -1137,11 +1137,11 @@ mod test { fn test_schedule_home_states() { use sleeper_list::SleeperList; use super::{Shutdown, Scheduler, SchedHandle}; - use std::unstable::run_in_bare_thread; + use std::unstable::Thread; use std::rt::thread::Thread; use std::sync::deque::BufferPool; - run_in_bare_thread(proc() { + Thread::start(proc() { let sleepers = SleeperList::new(); let mut pool = BufferPool::new(); let (normal_worker, normal_stealer) = pool.deque(); @@ -1260,7 +1260,7 @@ mod test { normal_thread.join(); special_thread.join(); - }); + }).join(); } //#[test] diff --git a/src/librustuv/lib.rs b/src/librustuv/lib.rs index c9bff2e80bfe6..96b66f616f6e7 100644 --- a/src/librustuv/lib.rs +++ b/src/librustuv/lib.rs @@ -472,7 +472,7 @@ fn local_loop() -> &'static mut uvio::UvIoFactory { #[cfg(test)] mod test { use std::mem::transmute; - use std::unstable::run_in_bare_thread; + use std::rt::Thread; use super::{slice_to_uv_buf, Loop}; @@ -496,10 +496,10 @@ mod test { #[test] fn loop_smoke_test() { - run_in_bare_thread(proc() { + Thread::start(proc() { let mut loop_ = Loop::new(); loop_.run(); loop_.close(); - }); + }).join(); } } diff --git a/src/librustuv/uvio.rs b/src/librustuv/uvio.rs index c42b17cc3256e..6a3b3eba563fa 100644 --- a/src/librustuv/uvio.rs +++ b/src/librustuv/uvio.rs @@ -28,7 +28,7 @@ use std::rt::rtio; use std::rt::rtio::{IoFactory, EventLoop}; use ai = std::io::net::addrinfo; -#[cfg(test)] use std::unstable::run_in_bare_thread; +#[cfg(test)] use std::rt::Thread; use super::{uv_error_to_io_error, Loop}; @@ -117,7 +117,7 @@ impl EventLoop for UvEventLoop { #[test] fn test_callback_run_once() { - run_in_bare_thread(proc() { + Thread::start(proc() { let mut event_loop = UvEventLoop::new(); let mut count = 0; let count_ptr: *mut int = &mut count; @@ -126,7 +126,7 @@ fn test_callback_run_once() { }); event_loop.run(); assert_eq!(count, 1); - }); + }).join(); } pub struct UvIoFactory { diff --git a/src/libstd/rt/local.rs b/src/libstd/rt/local.rs index 05d1f1764b59f..9f0ed8044800c 100644 --- a/src/libstd/rt/local.rs +++ b/src/libstd/rt/local.rs @@ -53,24 +53,24 @@ impl Local> for Task { #[cfg(test)] mod test { use option::{None, Option}; - use unstable::run_in_bare_thread; + use rt::thread::Thread; use super::*; use owned::Box; use rt::task::Task; #[test] fn thread_local_task_smoke_test() { - run_in_bare_thread(proc() { + Thread::start(proc() { let task = box Task::new(); Local::put(task); let task: Box = Local::take(); cleanup_task(task); - }); + }).join(); } #[test] fn thread_local_task_two_instances() { - run_in_bare_thread(proc() { + Thread::start(proc() { let task = box Task::new(); Local::put(task); let task: Box = Local::take(); @@ -79,12 +79,12 @@ mod test { Local::put(task); let task: Box = Local::take(); cleanup_task(task); - }); + }).join(); } #[test] fn borrow_smoke_test() { - run_in_bare_thread(proc() { + Thread::start(proc() { let task = box Task::new(); Local::put(task); @@ -93,12 +93,12 @@ mod test { } let task: Box = Local::take(); cleanup_task(task); - }); + }).join(); } #[test] fn borrow_with_return() { - run_in_bare_thread(proc() { + Thread::start(proc() { let task = box Task::new(); Local::put(task); @@ -108,12 +108,12 @@ mod test { let task: Box = Local::take(); cleanup_task(task); - }); + }).join(); } #[test] fn try_take() { - run_in_bare_thread(proc() { + Thread::start(proc() { let task = box Task::new(); Local::put(task); @@ -122,7 +122,7 @@ mod test { assert!(u.is_none()); cleanup_task(t); - }); + }).join(); } fn cleanup_task(mut t: Box) { diff --git a/src/libstd/unstable/mod.rs b/src/libstd/unstable/mod.rs index 8b07850263fe8..f464f70772d94 100644 --- a/src/libstd/unstable/mod.rs +++ b/src/libstd/unstable/mod.rs @@ -11,7 +11,6 @@ #![doc(hidden)] use libc::uintptr_t; -use kinds::Send; pub use core::finally; @@ -21,36 +20,6 @@ pub mod simd; pub mod sync; pub mod mutex; -/** - -Start a new thread outside of the current runtime context and wait -for it to terminate. - -The executing thread has no access to a task pointer and will be using -a normal large stack. -*/ -pub fn run_in_bare_thread(f: proc():Send) { - use rt::thread::Thread; - Thread::start(f).join() -} - -#[test] -fn test_run_in_bare_thread() { - let i = 100; - run_in_bare_thread(proc() { - assert_eq!(i, 100); - }); -} - -#[test] -fn test_run_in_bare_thread_exchange() { - // Does the exchange heap work without the runtime? - let i = box 100; - run_in_bare_thread(proc() { - assert!(i == box 100); - }); -} - /// Dynamically inquire about whether we're running under V. /// You should usually not use this unless your test definitely /// can't run correctly un-altered. Valgrind is there to help diff --git a/src/test/run-pass/foreign-call-no-runtime.rs b/src/test/run-pass/foreign-call-no-runtime.rs index b56847b2da0d6..989c09146b7d5 100644 --- a/src/test/run-pass/foreign-call-no-runtime.rs +++ b/src/test/run-pass/foreign-call-no-runtime.rs @@ -11,7 +11,7 @@ extern crate libc; use std::mem; -use std::unstable::run_in_bare_thread; +use std::rt::thread::Thread; #[link(name = "rustrt")] extern { @@ -21,10 +21,10 @@ extern { pub fn main() { unsafe { - run_in_bare_thread(proc() { + Thread::start(proc() { let i = &100; rust_dbg_call(callback, mem::transmute(i)); - }); + }).join(); } } From a6c1b981035d989baf0719a66f3401c2d139ddba Mon Sep 17 00:00:00 2001 From: Brian Anderson Date: Wed, 14 May 2014 01:36:12 -0700 Subject: [PATCH 2/3] std: Delete unused file --- src/libstd/io/flate.rs | 52 ------------------------------------------ 1 file changed, 52 deletions(-) delete mode 100644 src/libstd/io/flate.rs diff --git a/src/libstd/io/flate.rs b/src/libstd/io/flate.rs deleted file mode 100644 index 0cf00b2c1a9a7..0000000000000 --- a/src/libstd/io/flate.rs +++ /dev/null @@ -1,52 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -//! Some various other I/O types - -// FIXME(#3660): should move to libextra - -use prelude::*; -use super::*; - -/// A Writer decorator that compresses using the 'deflate' scheme -pub struct DeflateWriter { - priv inner_writer: W -} - -impl DeflateWriter { - pub fn new(inner_writer: W) -> DeflateWriter { - DeflateWriter { - inner_writer: inner_writer - } - } -} - -impl Writer for DeflateWriter { - fn write(&mut self, _buf: &[u8]) { fail!() } - - fn flush(&mut self) { fail!() } -} - -/// A Reader decorator that decompresses using the 'deflate' scheme -pub struct InflateReader { - priv inner_reader: R -} - -impl InflateReader { - pub fn new(inner_reader: R) -> InflateReader { - InflateReader { - inner_reader: inner_reader - } - } -} - -impl Reader for InflateReader { - fn read(&mut self, _buf: &mut [u8]) -> Option { fail!() } -} From 2103b5b3fa5dffbe54d2556d43b72454d49bdde1 Mon Sep 17 00:00:00 2001 From: Brian Anderson Date: Mon, 12 May 2014 21:02:27 -0700 Subject: [PATCH 3/3] core: Remove the unit module --- src/libcore/cmp.rs | 18 ++++++++++++++++- src/libcore/default.rs | 5 +++++ src/libcore/lib.rs | 1 - src/libcore/unit.rs | 45 ------------------------------------------ 4 files changed, 22 insertions(+), 47 deletions(-) delete mode 100644 src/libcore/unit.rs diff --git a/src/libcore/cmp.rs b/src/libcore/cmp.rs index f2b1c1cd4cde6..70a7fa53697a3 100644 --- a/src/libcore/cmp.rs +++ b/src/libcore/cmp.rs @@ -192,7 +192,23 @@ pub fn max(v1: T, v2: T) -> T { // Implementation of Eq/TotalEq for some primitive types #[cfg(not(test))] mod impls { - use cmp::{Ord, TotalOrd, Eq, TotalEq, Ordering}; + use cmp::{Ord, TotalOrd, Eq, TotalEq, Ordering, Equal}; + + impl Eq for () { + #[inline] + fn eq(&self, _other: &()) -> bool { true } + #[inline] + fn ne(&self, _other: &()) -> bool { false } + } + impl TotalEq for () {} + impl Ord for () { + #[inline] + fn lt(&self, _other: &()) -> bool { false } + } + impl TotalOrd for () { + #[inline] + fn cmp(&self, _other: &()) -> Ordering { Equal } + } // & pointers impl<'a, T: Eq> Eq for &'a T { diff --git a/src/libcore/default.rs b/src/libcore/default.rs index af65fcc5a779d..50ddfcc52f7be 100644 --- a/src/libcore/default.rs +++ b/src/libcore/default.rs @@ -16,6 +16,11 @@ pub trait Default { fn default() -> Self; } +impl Default for () { + #[inline] + fn default() -> () { () } +} + impl Default for @T { fn default() -> @T { @Default::default() } } diff --git a/src/libcore/lib.rs b/src/libcore/lib.rs index 4eab7e9d45d35..0f3c3ee2dc0e0 100644 --- a/src/libcore/lib.rs +++ b/src/libcore/lib.rs @@ -100,7 +100,6 @@ pub mod container; /* Core types and methods on primitives */ mod unicode; -mod unit; pub mod any; pub mod atomics; pub mod bool; diff --git a/src/libcore/unit.rs b/src/libcore/unit.rs deleted file mode 100644 index f55cb2d22360d..0000000000000 --- a/src/libcore/unit.rs +++ /dev/null @@ -1,45 +0,0 @@ -// Copyright 2012-2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -//! Functions for the unit type. - -#[cfg(not(test))] -use default::Default; -#[cfg(not(test))] -use cmp::{Eq, Equal, Ord, Ordering, TotalEq, TotalOrd}; - -#[cfg(not(test))] -impl Eq for () { - #[inline] - fn eq(&self, _other: &()) -> bool { true } - #[inline] - fn ne(&self, _other: &()) -> bool { false } -} - -#[cfg(not(test))] -impl Ord for () { - #[inline] - fn lt(&self, _other: &()) -> bool { false } -} - -#[cfg(not(test))] -impl TotalOrd for () { - #[inline] - fn cmp(&self, _other: &()) -> Ordering { Equal } -} - -#[cfg(not(test))] -impl TotalEq for () {} - -#[cfg(not(test))] -impl Default for () { - #[inline] - fn default() -> () { () } -}