diff options
Diffstat (limited to 'src/libstd/task')
| -rw-r--r-- | src/libstd/task/mod.rs | 95 | ||||
| -rw-r--r-- | src/libstd/task/rt.rs | 2 | ||||
| -rw-r--r-- | src/libstd/task/spawn.rs | 37 |
3 files changed, 5 insertions, 129 deletions
diff --git a/src/libstd/task/mod.rs b/src/libstd/task/mod.rs index c26349b220d..6de0c78d00b 100644 --- a/src/libstd/task/mod.rs +++ b/src/libstd/task/mod.rs @@ -44,7 +44,6 @@ use result::Result; use result; use rt::{context, OldTaskContext, TaskContext}; use rt::local::Local; -use task::rt::{task_id, sched_id}; use unstable::finally::Finally; use util; @@ -58,18 +57,6 @@ mod local_data_priv; pub mod rt; pub mod spawn; -/// A handle to a scheduler -#[deriving(Eq)] -pub enum Scheduler { - SchedulerHandle(sched_id) -} - -/// A handle to a task -#[deriving(Eq)] -pub enum Task { - TaskHandle(task_id) -} - /** * Indicates the manner in which a task exited. * @@ -92,23 +79,8 @@ pub enum TaskResult { pub enum SchedMode { /// Run task on the default scheduler DefaultScheduler, - /// Run task on the current scheduler - CurrentScheduler, - /// Run task on a specific scheduler - ExistingScheduler(Scheduler), - /** - * Tasks are scheduled on the main OS thread - * - * The main OS thread is the thread used to launch the runtime which, - * in most cases, is the process's initial thread as created by the OS. - */ - PlatformThread, /// All tasks run in the same OS thread SingleThreaded, - /// Tasks are distributed among available CPUs - ThreadPerTask, - /// Tasks are distributed among a fixed number of OS threads - ManualThreads(uint), } /** @@ -118,17 +90,9 @@ pub enum SchedMode { * * * sched_mode - The operating mode of the scheduler * - * * foreign_stack_size - The size of the foreign stack, in bytes - * - * Rust code runs on Rust-specific stacks. When Rust code calls foreign - * code (via functions in foreign modules) it switches to a typical, large - * stack appropriate for running code written in languages like C. By - * default these foreign stacks have unspecified size, but with this - * option their size can be precisely specified. */ pub struct SchedOpts { mode: SchedMode, - foreign_stack_size: Option<uint>, } /** @@ -446,7 +410,6 @@ pub fn default_task_opts() -> TaskOpts { notify_chan: None, sched: SchedOpts { mode: DefaultScheduler, - foreign_stack_size: None } } } @@ -591,18 +554,6 @@ pub fn failing() -> bool { } } -pub fn get_task() -> Task { - //! Get a handle to the running task - - unsafe { - TaskHandle(rt::get_task_id()) - } -} - -pub fn get_scheduler() -> Scheduler { - SchedulerHandle(unsafe { rt::rust_get_sched_id() }) -} - /** * Temporarily make the task unkillable * @@ -935,13 +886,6 @@ fn test_try_fail() { } #[test] -#[should_fail] -#[ignore(cfg(windows))] -fn test_spawn_sched_no_threads() { - do spawn_sched(ManualThreads(0u)) { } -} - -#[test] fn test_spawn_sched() { let (po, ch) = stream::<()>(); let ch = SharedChan::new(ch); @@ -1108,17 +1052,6 @@ fn test_avoid_copying_the_body_unlinked() { } #[test] -fn test_platform_thread() { - let (po, ch) = stream(); - let mut builder = task(); - builder.sched_mode(PlatformThread); - do builder.spawn { - ch.send(()); - } - po.recv(); -} - -#[test] #[ignore(cfg(windows))] #[should_fail] fn test_unkillable() { @@ -1222,34 +1155,6 @@ fn test_child_doesnt_ref_parent() { } #[test] -fn test_spawn_thread_on_demand() { - let (port, chan) = comm::stream(); - - do spawn_sched(ManualThreads(2)) || { - unsafe { - let max_threads = rt::rust_sched_threads(); - assert_eq!(max_threads as int, 2); - let running_threads = rt::rust_sched_current_nonlazy_threads(); - assert_eq!(running_threads as int, 1); - - let (port2, chan2) = comm::stream(); - - do spawn_sched(CurrentScheduler) || { - chan2.send(()); - } - - let running_threads2 = rt::rust_sched_current_nonlazy_threads(); - assert_eq!(running_threads2 as int, 2); - - port2.recv(); - chan.send(()); - } - } - - port.recv(); -} - -#[test] fn test_simple_newsched_spawn() { use rt::test::run_in_newsched_task; diff --git a/src/libstd/task/rt.rs b/src/libstd/task/rt.rs index 3720bc585cc..13c51230dc2 100644 --- a/src/libstd/task/rt.rs +++ b/src/libstd/task/rt.rs @@ -36,8 +36,6 @@ extern { pub fn rust_get_sched_id() -> sched_id; pub fn rust_new_sched(num_threads: libc::uintptr_t) -> sched_id; - pub fn rust_sched_threads() -> libc::size_t; - pub fn rust_sched_current_nonlazy_threads() -> libc::size_t; pub fn get_task_id() -> task_id; #[rust_stack] diff --git a/src/libstd/task/spawn.rs b/src/libstd/task/spawn.rs index 749db307012..54e46826976 100644 --- a/src/libstd/task/spawn.rs +++ b/src/libstd/task/spawn.rs @@ -84,9 +84,8 @@ use local_data; use task::local_data_priv::{local_get, local_set, OldHandle}; use task::rt::rust_task; use task::rt; -use task::{Failure, ManualThreads, PlatformThread, SchedOpts, SingleThreaded}; -use task::{Success, TaskOpts, TaskResult, ThreadPerTask}; -use task::{ExistingScheduler, SchedulerHandle}; +use task::{Failure}; +use task::{Success, TaskOpts, TaskResult}; use task::unkillable; use to_bytes::IterBytes; use uint; @@ -747,7 +746,7 @@ fn spawn_raw_oldsched(mut opts: TaskOpts, f: ~fn()) { // Create child task. let new_task = match opts.sched.mode { DefaultScheduler => rt::new_task(), - _ => new_task_in_sched(opts.sched) + _ => new_task_in_sched() }; assert!(!new_task.is_null()); // Getting killed after here would leak the task. @@ -805,35 +804,9 @@ fn spawn_raw_oldsched(mut opts: TaskOpts, f: ~fn()) { return result; } - fn new_task_in_sched(opts: SchedOpts) -> *rust_task { - if opts.foreign_stack_size != None { - fail!("foreign_stack_size scheduler option unimplemented"); - } - - let num_threads = match opts.mode { - DefaultScheduler - | CurrentScheduler - | ExistingScheduler(*) - | PlatformThread => 0u, /* Won't be used */ - SingleThreaded => 1u, - ThreadPerTask => { - fail!("ThreadPerTask scheduling mode unimplemented") - } - ManualThreads(threads) => { - if threads == 0u { - fail!("can not create a scheduler with no threads"); - } - threads - } - }; - + fn new_task_in_sched() -> *rust_task { unsafe { - let sched_id = match opts.mode { - CurrentScheduler => rt::rust_get_sched_id(), - ExistingScheduler(SchedulerHandle(id)) => id, - PlatformThread => rt::rust_osmain_sched_id(), - _ => rt::rust_new_sched(num_threads) - }; + let sched_id = rt::rust_new_sched(1); rt::rust_new_task_in_sched(sched_id) } } |
