about summary refs log tree commit diff
path: root/src/libstd
diff options
context:
space:
mode:
authorAaron Turon <aturon@mozilla.com>2014-11-14 14:38:41 -0800
committerAaron Turon <aturon@mozilla.com>2014-11-20 17:19:24 -0800
commit40c78ab037c70d61eb4f8c95c7a4fec8f098644b (patch)
tree83d66a065a6c79f702c62d7abaf54145353a2dc4 /src/libstd
parenta68ec98166bf638c6cbf4036f51036012695718d (diff)
downloadrust-40c78ab037c70d61eb4f8c95c7a4fec8f098644b.tar.gz
rust-40c78ab037c70d61eb4f8c95c7a4fec8f098644b.zip
Fallout from libgreen and libnative removal
Diffstat (limited to 'src/libstd')
-rw-r--r--src/libstd/io/process.rs2
-rw-r--r--src/libstd/lib.rs1
-rw-r--r--src/libstd/rt/mod.rs12
-rw-r--r--src/libstd/sys/common/helper_thread.rs2
-rw-r--r--src/libstd/task.rs126
5 files changed, 19 insertions, 124 deletions
diff --git a/src/libstd/io/process.rs b/src/libstd/io/process.rs
index 592ec0681a9..d4d24c1e12f 100644
--- a/src/libstd/io/process.rs
+++ b/src/libstd/io/process.rs
@@ -740,8 +740,6 @@ impl Drop for Process {
 mod tests {
     #![allow(unused_imports)]
 
-    extern crate native;
-
     use super::*;
     use prelude::*;
     use io::timer::*;
diff --git a/src/libstd/lib.rs b/src/libstd/lib.rs
index 70b30997e18..c27faea74bb 100644
--- a/src/libstd/lib.rs
+++ b/src/libstd/lib.rs
@@ -117,7 +117,6 @@
 
 #![reexport_test_harness_main = "test_main"]
 
-#[cfg(test)] extern crate green;
 #[cfg(test)] #[phase(plugin, link)] extern crate log;
 
 extern crate alloc;
diff --git a/src/libstd/rt/mod.rs b/src/libstd/rt/mod.rs
index 322df17f4f1..b6e57186afe 100644
--- a/src/libstd/rt/mod.rs
+++ b/src/libstd/rt/mod.rs
@@ -58,7 +58,7 @@ Several modules in `core` are clients of `rt`:
 
 use failure;
 use rustrt;
-use startup;
+use os;
 
 // Reexport some of our utilities which are expected by other crates.
 pub use self::util::{default_sched_threads, min_stack, running_on_valgrind};
@@ -66,9 +66,9 @@ pub use self::util::{default_sched_threads, min_stack, running_on_valgrind};
 // Reexport functionality from librustrt and other crates underneath the
 // standard library which work together to create the entire runtime.
 pub use alloc::heap;
-pub use rustrt::{task, local, mutex, exclusive, stack, args, rtio, thread};
+pub use rustrt::{task, local, mutex, exclusive, stack, args, thread};
 pub use rustrt::{Stdio, Stdout, Stderr, begin_unwind, begin_unwind_fmt};
-pub use rustrt::{bookkeeping, at_exit, unwind, DEFAULT_ERROR_CODE, Runtime};
+pub use rustrt::{at_exit, unwind, DEFAULT_ERROR_CODE};
 
 // Simple backtrace functionality (to print on panic)
 pub mod backtrace;
@@ -95,7 +95,7 @@ static OS_DEFAULT_STACK_ESTIMATE: uint = 2 * (1 << 20);
 #[cfg(not(test))]
 #[lang = "start"]
 fn lang_start(main: *const u8, argc: int, argv: *const *const u8) -> int {
-    use std::mem;
+    use mem;
     start(argc, argv, proc() {
         let main: extern "Rust" fn() = unsafe { mem::transmute(main) };
         main();
@@ -147,8 +147,8 @@ pub fn start(argc: int, argv: *const *const u8, main: proc()) -> int {
     init(argc, argv);
     let mut exit_code = None;
     let mut main = Some(main);
-    let mut task = task::new((my_stack_bottom, my_stack_top),
-                             rt::thread::main_guard_page());
+    let mut task = Task::new(Some((my_stack_bottom, my_stack_top)),
+                             Some(rt::thread::main_guard_page()));
     task.name = Some(str::Slice("<main>"));
     drop(task.run(|| {
         unsafe {
diff --git a/src/libstd/sys/common/helper_thread.rs b/src/libstd/sys/common/helper_thread.rs
index 87907fde277..d7c286bf0b9 100644
--- a/src/libstd/sys/common/helper_thread.rs
+++ b/src/libstd/sys/common/helper_thread.rs
@@ -21,7 +21,7 @@
 //! time.
 
 use mem;
-use rt::bookkeeping;
+use rustrt::bookkeeping;
 use rt::mutex::StaticNativeMutex;
 use rt;
 use cell::UnsafeCell;
diff --git a/src/libstd/task.rs b/src/libstd/task.rs
index c7e31dae3d4..8da32ba4b89 100644
--- a/src/libstd/task.rs
+++ b/src/libstd/task.rs
@@ -11,11 +11,7 @@
 //! Task creation
 //!
 //! An executing Rust program consists of a collection of tasks, each
-//! with their own stack and local state. A Rust task is typically
-//! backed by an operating system thread, making tasks 'just threads',
-//! but may also be implemented via other strategies as well
-//! (e.g. Rust comes with the [`green`](../../green/index.html)
-//! scheduling crate for creating tasks backed by green threads).
+//! with their own stack and local state.
 //!
 //! Tasks generally have their memory *isolated* from each other by
 //! virtue of Rust's owned types (which of course may only be owned by
@@ -36,13 +32,6 @@
 //! the main task panics the application will exit with a non-zero
 //! exit code.
 //!
-//! # Basic task scheduling
-//!
-//! By default, every task is created with the same "flavor" as the calling task.
-//! This flavor refers to the scheduling mode, with two possibilities currently
-//! being 1:1 and M:N modes. Green (M:N) tasks are cooperatively scheduled and
-//! native (1:1) tasks are scheduled by the OS kernel.
-//!
 //! ## Example
 //!
 //! ```rust
@@ -50,46 +39,6 @@
 //!     println!("Hello, World!");
 //! })
 //! ```
-//!
-//! # Advanced task scheduling
-//!
-//! Task spawning can also be configured to use a particular scheduler, to
-//! redirect the new task's output, or to yield a `future` representing the
-//! task's final result. The configuration is established using the
-//! `TaskBuilder` API:
-//!
-//! ## Example
-//!
-//! ```rust
-//! extern crate green;
-//! extern crate native;
-//!
-//! use std::task::TaskBuilder;
-//! use green::{SchedPool, PoolConfig, GreenTaskBuilder};
-//! use native::NativeTaskBuilder;
-//!
-//! # fn main() {
-//! // Create a green scheduler pool with the default configuration
-//! let mut pool = SchedPool::new(PoolConfig::new());
-//!
-//! // Spawn a task in the green pool
-//! let mut fut_green = TaskBuilder::new().green(&mut pool).try_future(proc() {
-//!     /* ... */
-//! });
-//!
-//! // Spawn a native task
-//! let mut fut_native = TaskBuilder::new().native().try_future(proc() {
-//!     /* ... */
-//! });
-//!
-//! // Wait for both tasks to finish, recording their outcome
-//! let res_green  = fut_green.unwrap();
-//! let res_native = fut_native.unwrap();
-//!
-//! // Shut down the green scheduler pool
-//! pool.shutdown();
-//! # }
-//! ```
 
 #![unstable = "The task spawning model will be changed as part of runtime reform, and the module \
                will likely be renamed from `task` to `thread`."]
@@ -108,26 +57,6 @@ use str::{Str, SendStr, IntoMaybeOwned};
 use string::{String, ToString};
 use sync::Future;
 
-/// A means of spawning a task
-pub trait Spawner {
-    /// Spawn a task, given low-level task options.
-    fn spawn(self, opts: task::TaskOpts, f: proc():Send);
-}
-
-/// The default task spawner, which spawns siblings to the current task.
-pub struct SiblingSpawner;
-
-impl Spawner for SiblingSpawner {
-    fn spawn(self, opts: task::TaskOpts, f: proc():Send) {
-        // bind tb to provide type annotation
-        let tb: Option<Box<Task>> = Local::try_take();
-        match tb {
-            Some(t) => t.spawn_sibling(opts, f),
-            None => panic!("need a local task to spawn a sibling task"),
-        };
-    }
-}
-
 /// The task builder type.
 ///
 /// Provides detailed control over the properties and behavior of new tasks.
@@ -139,7 +68,7 @@ impl Spawner for SiblingSpawner {
 // when you try to reuse the builder to spawn a new task. We'll just
 // sidestep that whole issue by making builders uncopyable and making
 // the run function move them in.
-pub struct TaskBuilder<S = SiblingSpawner> {
+pub struct TaskBuilder {
     // A name for the task-to-be, for identification in panic messages
     name: Option<SendStr>,
     // The size of the stack for the spawned task
@@ -148,88 +77,60 @@ pub struct TaskBuilder<S = SiblingSpawner> {
     stdout: Option<Box<Writer + Send>>,
     // Task-local stderr
     stderr: Option<Box<Writer + Send>>,
-    // The mechanics of actually spawning the task (i.e.: green or native)
-    spawner: S,
     // Optionally wrap the eventual task body
     gen_body: Option<proc(v: proc():Send):Send -> proc():Send>,
     nocopy: marker::NoCopy,
 }
 
-impl TaskBuilder<SiblingSpawner> {
+impl TaskBuilder {
     /// Generate the base configuration for spawning a task, off of which more
     /// configuration methods can be chained.
-    pub fn new() -> TaskBuilder<SiblingSpawner> {
+    pub fn new() -> TaskBuilder {
         TaskBuilder {
             name: None,
             stack_size: None,
             stdout: None,
             stderr: None,
-            spawner: SiblingSpawner,
             gen_body: None,
             nocopy: marker::NoCopy,
         }
     }
 }
 
-impl<S: Spawner> TaskBuilder<S> {
+impl TaskBuilder {
     /// Name the task-to-be. Currently the name is used for identification
     /// only in panic messages.
     #[unstable = "IntoMaybeOwned will probably change."]
-    pub fn named<T: IntoMaybeOwned<'static>>(mut self, name: T) -> TaskBuilder<S> {
+    pub fn named<T: IntoMaybeOwned<'static>>(mut self, name: T) -> TaskBuilder {
         self.name = Some(name.into_maybe_owned());
         self
     }
 
     /// Set the size of the stack for the new task.
-    pub fn stack_size(mut self, size: uint) -> TaskBuilder<S> {
+    pub fn stack_size(mut self, size: uint) -> TaskBuilder {
         self.stack_size = Some(size);
         self
     }
 
     /// Redirect task-local stdout.
     #[experimental = "May not want to make stdio overridable here."]
-    pub fn stdout(mut self, stdout: Box<Writer + Send>) -> TaskBuilder<S> {
+    pub fn stdout(mut self, stdout: Box<Writer + Send>) -> TaskBuilder {
         self.stdout = Some(stdout);
         self
     }
 
     /// Redirect task-local stderr.
     #[experimental = "May not want to make stdio overridable here."]
-    pub fn stderr(mut self, stderr: Box<Writer + Send>) -> TaskBuilder<S> {
+    pub fn stderr(mut self, stderr: Box<Writer + Send>) -> TaskBuilder {
         self.stderr = Some(stderr);
         self
     }
 
-    /// Set the spawning mechanism for the task.
-    ///
-    /// The `TaskBuilder` API configures a task to be spawned, but defers to the
-    /// "spawner" to actually create and spawn the task. The `spawner` method
-    /// should not be called directly by `TaskBuiler` clients. It is intended
-    /// for use by downstream crates (like `native` and `green`) that implement
-    /// tasks. These downstream crates then add extension methods to the
-    /// builder, like `.native()` and `.green(pool)`, that actually set the
-    /// spawner.
-    pub fn spawner<T: Spawner>(self, spawner: T) -> TaskBuilder<T> {
-        // repackage the entire TaskBuilder since its type is changing.
-        let TaskBuilder {
-            name, stack_size, stdout, stderr, spawner: _, gen_body, nocopy
-        } = self;
-        TaskBuilder {
-            name: name,
-            stack_size: stack_size,
-            stdout: stdout,
-            stderr: stderr,
-            spawner: spawner,
-            gen_body: gen_body,
-            nocopy: nocopy,
-        }
-    }
-
     // Where spawning actually happens (whether yielding a future or not)
     fn spawn_internal(self, f: proc():Send,
                       on_exit: Option<proc(Result<(), Box<Any + Send>>):Send>) {
         let TaskBuilder {
-            name, stack_size, stdout, stderr, spawner, mut gen_body, nocopy: _
+            name, stack_size, stdout, stderr, mut gen_body, nocopy: _
         } = self;
         let f = match gen_body.take() {
             Some(gen) => gen(f),
@@ -348,11 +249,8 @@ pub fn name() -> Option<String> {
 /// Yield control to the task scheduler.
 #[unstable = "Name will change."]
 pub fn deschedule() {
-    use rt::local::Local;
-
-    // FIXME(#7544): Optimize this, since we know we won't block.
-    let task: Box<Task> = Local::take();
-    task.yield_now();
+    use rt::task::Task;
+    Task::yield_now();
 }
 
 /// True if the running task is currently panicking (e.g. will return `true` inside a