Skip to content

Commit

Permalink
std: Remove run_in_bare_thread
Browse files Browse the repository at this point in the history
  • Loading branch information
brson authored and alexcrichton committed May 15, 2014
1 parent b05af1f commit 514fc30
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 54 deletions.
6 changes: 3 additions & 3 deletions src/libgreen/sched.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -1260,7 +1260,7 @@ mod test {

normal_thread.join();
special_thread.join();
});
}).join();
}

//#[test]
Expand Down
6 changes: 3 additions & 3 deletions src/librustuv/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};

Expand All @@ -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();
}
}
6 changes: 3 additions & 3 deletions src/librustuv/uvio.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ use std::rt::rtio;
use std::rt::rtio::{ProcessConfig, 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};

Expand Down Expand Up @@ -116,7 +116,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;
Expand All @@ -125,7 +125,7 @@ fn test_callback_run_once() {
});
event_loop.run();
assert_eq!(count, 1);
});
}).join();
}

pub struct UvIoFactory {
Expand Down
22 changes: 11 additions & 11 deletions src/libstd/rt/local.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,24 +53,24 @@ impl Local<local_ptr::Borrowed<Task>> 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<Task> = 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<Task> = Local::take();
Expand All @@ -79,12 +79,12 @@ mod test {
Local::put(task);
let task: Box<Task> = 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);

Expand All @@ -93,12 +93,12 @@ mod test {
}
let task: Box<Task> = 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);

Expand All @@ -108,12 +108,12 @@ mod test {

let task: Box<Task> = 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);

Expand All @@ -122,7 +122,7 @@ mod test {
assert!(u.is_none());

cleanup_task(t);
});
}).join();
}

fn cleanup_task(mut t: Box<Task>) {
Expand Down
31 changes: 0 additions & 31 deletions src/libstd/unstable/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
#![doc(hidden)]

use libc::uintptr_t;
use kinds::Send;

pub use core::finally;

Expand All @@ -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
Expand Down
6 changes: 3 additions & 3 deletions src/test/run-pass/foreign-call-no-runtime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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();
}
}

Expand Down

0 comments on commit 514fc30

Please sign in to comment.