Skip to content

Commit 40c78ab

Browse files
committed
Fallout from libgreen and libnative removal
1 parent a68ec98 commit 40c78ab

File tree

28 files changed

+47
-349
lines changed

28 files changed

+47
-349
lines changed

mk/crates.mk

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
#
3838
# DEPS_<crate>
3939
# These lists are the dependencies of the <crate> that is to be built.
40-
# Rust dependencies are listed bare (i.e. std, green) and native
40+
# Rust dependencies are listed bare (i.e. std) and native
4141
# dependencies have a "native:" prefix (i.e. native:hoedown). All deps
4242
# will be built before the crate itself is built.
4343
#
@@ -49,7 +49,7 @@
4949
# automatically generated for all stage/host/target combinations.
5050
################################################################################
5151

52-
TARGET_CRATES := libc std green flate arena term \
52+
TARGET_CRATES := libc std flate arena term \
5353
serialize sync getopts collections test time rand \
5454
log regex graphviz core rbml alloc rustrt \
5555
unicode
@@ -66,7 +66,6 @@ DEPS_rustrt := alloc core libc collections native:rustrt_native
6666
DEPS_std := core libc rand alloc collections rustrt sync unicode \
6767
native:rust_builtin native:backtrace
6868
DEPS_graphviz := std
69-
DEPS_green := std native:context_switch
7069
DEPS_syntax := std term serialize log fmt_macros arena libc
7170
DEPS_rustc_trans := rustc rustc_back rustc_llvm libc
7271
DEPS_rustc := syntax flate arena serialize getopts rbml \

src/README.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@ Source layout:
99
| `libcore/` | The Rust core library |
1010
| `libdebug/` | Debugging utilities |
1111
| `libstd/` | The standard library (imported and linked by default) |
12-
| `libgreen/` | The M:N runtime library |
13-
| `libnative/` | The 1:1 runtime library |
1412
| `libsyntax/` | The Rust parser and pretty-printer |
1513
| `libtest/` | Rust's test-runner code |
1614
| ------------------- | --------------------------------------------------------- |

src/doc/reference.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -999,14 +999,14 @@ An example of what will and will not work for `use` items:
999999

10001000
```
10011001
# #![allow(unused_imports)]
1002-
use foo::native::start; // good: foo is at the root of the crate
1002+
use foo::core::iter; // good: foo is at the root of the crate
10031003
use foo::baz::foobaz; // good: foo is at the root of the crate
10041004
10051005
mod foo {
1006-
extern crate native;
1006+
extern crate core;
10071007
1008-
use foo::native::start; // good: foo is at crate root
1009-
// use native::start; // bad: native is not at the crate root
1008+
use foo::core::iter; // good: foo is at crate root
1009+
// use core::iter; // bad: native is not at the crate root
10101010
use self::baz::foobaz; // good: self refers to module 'foo'
10111011
use foo::bar::foobar; // good: foo is at crate root
10121012

src/liballoc/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,6 @@ extern crate libc;
7373

7474
// Allow testing this library
7575

76-
#[cfg(test)] extern crate native;
7776
#[cfg(test)] #[phase(plugin, link)] extern crate std;
7877
#[cfg(test)] #[phase(plugin, link)] extern crate log;
7978

src/libcollections/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@
3131
extern crate unicode;
3232
extern crate alloc;
3333

34-
#[cfg(test)] extern crate native;
3534
#[cfg(test)] extern crate test;
3635

3736
#[cfg(test)] #[phase(plugin, link)] extern crate std;

src/liblibc/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,6 @@ extern crate core;
8383

8484
#[cfg(test)] extern crate std;
8585
#[cfg(test)] extern crate test;
86-
#[cfg(test)] extern crate native;
8786

8887
pub use self::Nullable::*;
8988

src/librand/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ extern crate core;
3333

3434
#[cfg(test)] #[phase(plugin, link)] extern crate std;
3535
#[cfg(test)] #[phase(plugin, link)] extern crate log;
36-
#[cfg(test)] extern crate native;
3736

3837
use core::prelude::*;
3938

src/librustrt/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ extern crate collections;
3030

3131
#[cfg(test)] extern crate "rustrt" as realrustrt;
3232
#[cfg(test)] extern crate test;
33-
#[cfg(test)] extern crate native;
3433

3534
#[cfg(test)] #[phase(plugin, link)] extern crate std;
3635

src/librustrt/stack_overflow.rs

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -65,14 +65,7 @@ pub unsafe fn report() {
6565
#[cfg(any(windows, target_os = "linux", target_os = "macos"))]
6666
unsafe fn get_task_guard_page() -> Option<uint> {
6767
let task: Option<*mut Task> = Local::try_unsafe_borrow();
68-
69-
task.map(|task| {
70-
let runtime = (*task).take_runtime();
71-
let guard = runtime.stack_guard();
72-
(*task).put_runtime(runtime);
73-
74-
guard.unwrap_or(0)
75-
})
68+
task.map(|task| (&*task).stack_guard().unwrap_or(0))
7669
}
7770

7871
#[cfg(windows)]

src/libstd/io/process.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -740,8 +740,6 @@ impl Drop for Process {
740740
mod tests {
741741
#![allow(unused_imports)]
742742

743-
extern crate native;
744-
745743
use super::*;
746744
use prelude::*;
747745
use io::timer::*;

src/libstd/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,6 @@
117117

118118
#![reexport_test_harness_main = "test_main"]
119119

120-
#[cfg(test)] extern crate green;
121120
#[cfg(test)] #[phase(plugin, link)] extern crate log;
122121

123122
extern crate alloc;

src/libstd/rt/mod.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -58,17 +58,17 @@ Several modules in `core` are clients of `rt`:
5858

5959
use failure;
6060
use rustrt;
61-
use startup;
61+
use os;
6262

6363
// Reexport some of our utilities which are expected by other crates.
6464
pub use self::util::{default_sched_threads, min_stack, running_on_valgrind};
6565

6666
// Reexport functionality from librustrt and other crates underneath the
6767
// standard library which work together to create the entire runtime.
6868
pub use alloc::heap;
69-
pub use rustrt::{task, local, mutex, exclusive, stack, args, rtio, thread};
69+
pub use rustrt::{task, local, mutex, exclusive, stack, args, thread};
7070
pub use rustrt::{Stdio, Stdout, Stderr, begin_unwind, begin_unwind_fmt};
71-
pub use rustrt::{bookkeeping, at_exit, unwind, DEFAULT_ERROR_CODE, Runtime};
71+
pub use rustrt::{at_exit, unwind, DEFAULT_ERROR_CODE};
7272

7373
// Simple backtrace functionality (to print on panic)
7474
pub mod backtrace;
@@ -95,7 +95,7 @@ static OS_DEFAULT_STACK_ESTIMATE: uint = 2 * (1 << 20);
9595
#[cfg(not(test))]
9696
#[lang = "start"]
9797
fn lang_start(main: *const u8, argc: int, argv: *const *const u8) -> int {
98-
use std::mem;
98+
use mem;
9999
start(argc, argv, proc() {
100100
let main: extern "Rust" fn() = unsafe { mem::transmute(main) };
101101
main();
@@ -147,8 +147,8 @@ pub fn start(argc: int, argv: *const *const u8, main: proc()) -> int {
147147
init(argc, argv);
148148
let mut exit_code = None;
149149
let mut main = Some(main);
150-
let mut task = task::new((my_stack_bottom, my_stack_top),
151-
rt::thread::main_guard_page());
150+
let mut task = Task::new(Some((my_stack_bottom, my_stack_top)),
151+
Some(rt::thread::main_guard_page()));
152152
task.name = Some(str::Slice("<main>"));
153153
drop(task.run(|| {
154154
unsafe {

src/libstd/sys/common/helper_thread.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
//! time.
2222
2323
use mem;
24-
use rt::bookkeeping;
24+
use rustrt::bookkeeping;
2525
use rt::mutex::StaticNativeMutex;
2626
use rt;
2727
use cell::UnsafeCell;

src/libstd/task.rs

Lines changed: 12 additions & 114 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,7 @@
1111
//! Task creation
1212
//!
1313
//! An executing Rust program consists of a collection of tasks, each
14-
//! with their own stack and local state. A Rust task is typically
15-
//! backed by an operating system thread, making tasks 'just threads',
16-
//! but may also be implemented via other strategies as well
17-
//! (e.g. Rust comes with the [`green`](../../green/index.html)
18-
//! scheduling crate for creating tasks backed by green threads).
14+
//! with their own stack and local state.
1915
//!
2016
//! Tasks generally have their memory *isolated* from each other by
2117
//! virtue of Rust's owned types (which of course may only be owned by
@@ -36,60 +32,13 @@
3632
//! the main task panics the application will exit with a non-zero
3733
//! exit code.
3834
//!
39-
//! # Basic task scheduling
40-
//!
41-
//! By default, every task is created with the same "flavor" as the calling task.
42-
//! This flavor refers to the scheduling mode, with two possibilities currently
43-
//! being 1:1 and M:N modes. Green (M:N) tasks are cooperatively scheduled and
44-
//! native (1:1) tasks are scheduled by the OS kernel.
45-
//!
4635
//! ## Example
4736
//!
4837
//! ```rust
4938
//! spawn(proc() {
5039
//! println!("Hello, World!");
5140
//! })
5241
//! ```
53-
//!
54-
//! # Advanced task scheduling
55-
//!
56-
//! Task spawning can also be configured to use a particular scheduler, to
57-
//! redirect the new task's output, or to yield a `future` representing the
58-
//! task's final result. The configuration is established using the
59-
//! `TaskBuilder` API:
60-
//!
61-
//! ## Example
62-
//!
63-
//! ```rust
64-
//! extern crate green;
65-
//! extern crate native;
66-
//!
67-
//! use std::task::TaskBuilder;
68-
//! use green::{SchedPool, PoolConfig, GreenTaskBuilder};
69-
//! use native::NativeTaskBuilder;
70-
//!
71-
//! # fn main() {
72-
//! // Create a green scheduler pool with the default configuration
73-
//! let mut pool = SchedPool::new(PoolConfig::new());
74-
//!
75-
//! // Spawn a task in the green pool
76-
//! let mut fut_green = TaskBuilder::new().green(&mut pool).try_future(proc() {
77-
//! /* ... */
78-
//! });
79-
//!
80-
//! // Spawn a native task
81-
//! let mut fut_native = TaskBuilder::new().native().try_future(proc() {
82-
//! /* ... */
83-
//! });
84-
//!
85-
//! // Wait for both tasks to finish, recording their outcome
86-
//! let res_green = fut_green.unwrap();
87-
//! let res_native = fut_native.unwrap();
88-
//!
89-
//! // Shut down the green scheduler pool
90-
//! pool.shutdown();
91-
//! # }
92-
//! ```
9342
9443
#![unstable = "The task spawning model will be changed as part of runtime reform, and the module \
9544
will likely be renamed from `task` to `thread`."]
@@ -108,26 +57,6 @@ use str::{Str, SendStr, IntoMaybeOwned};
10857
use string::{String, ToString};
10958
use sync::Future;
11059

111-
/// A means of spawning a task
112-
pub trait Spawner {
113-
/// Spawn a task, given low-level task options.
114-
fn spawn(self, opts: task::TaskOpts, f: proc():Send);
115-
}
116-
117-
/// The default task spawner, which spawns siblings to the current task.
118-
pub struct SiblingSpawner;
119-
120-
impl Spawner for SiblingSpawner {
121-
fn spawn(self, opts: task::TaskOpts, f: proc():Send) {
122-
// bind tb to provide type annotation
123-
let tb: Option<Box<Task>> = Local::try_take();
124-
match tb {
125-
Some(t) => t.spawn_sibling(opts, f),
126-
None => panic!("need a local task to spawn a sibling task"),
127-
};
128-
}
129-
}
130-
13160
/// The task builder type.
13261
///
13362
/// Provides detailed control over the properties and behavior of new tasks.
@@ -139,7 +68,7 @@ impl Spawner for SiblingSpawner {
13968
// when you try to reuse the builder to spawn a new task. We'll just
14069
// sidestep that whole issue by making builders uncopyable and making
14170
// the run function move them in.
142-
pub struct TaskBuilder<S = SiblingSpawner> {
71+
pub struct TaskBuilder {
14372
// A name for the task-to-be, for identification in panic messages
14473
name: Option<SendStr>,
14574
// The size of the stack for the spawned task
@@ -148,88 +77,60 @@ pub struct TaskBuilder<S = SiblingSpawner> {
14877
stdout: Option<Box<Writer + Send>>,
14978
// Task-local stderr
15079
stderr: Option<Box<Writer + Send>>,
151-
// The mechanics of actually spawning the task (i.e.: green or native)
152-
spawner: S,
15380
// Optionally wrap the eventual task body
15481
gen_body: Option<proc(v: proc():Send):Send -> proc():Send>,
15582
nocopy: marker::NoCopy,
15683
}
15784

158-
impl TaskBuilder<SiblingSpawner> {
85+
impl TaskBuilder {
15986
/// Generate the base configuration for spawning a task, off of which more
16087
/// configuration methods can be chained.
161-
pub fn new() -> TaskBuilder<SiblingSpawner> {
88+
pub fn new() -> TaskBuilder {
16289
TaskBuilder {
16390
name: None,
16491
stack_size: None,
16592
stdout: None,
16693
stderr: None,
167-
spawner: SiblingSpawner,
16894
gen_body: None,
16995
nocopy: marker::NoCopy,
17096
}
17197
}
17298
}
17399

174-
impl<S: Spawner> TaskBuilder<S> {
100+
impl TaskBuilder {
175101
/// Name the task-to-be. Currently the name is used for identification
176102
/// only in panic messages.
177103
#[unstable = "IntoMaybeOwned will probably change."]
178-
pub fn named<T: IntoMaybeOwned<'static>>(mut self, name: T) -> TaskBuilder<S> {
104+
pub fn named<T: IntoMaybeOwned<'static>>(mut self, name: T) -> TaskBuilder {
179105
self.name = Some(name.into_maybe_owned());
180106
self
181107
}
182108

183109
/// Set the size of the stack for the new task.
184-
pub fn stack_size(mut self, size: uint) -> TaskBuilder<S> {
110+
pub fn stack_size(mut self, size: uint) -> TaskBuilder {
185111
self.stack_size = Some(size);
186112
self
187113
}
188114

189115
/// Redirect task-local stdout.
190116
#[experimental = "May not want to make stdio overridable here."]
191-
pub fn stdout(mut self, stdout: Box<Writer + Send>) -> TaskBuilder<S> {
117+
pub fn stdout(mut self, stdout: Box<Writer + Send>) -> TaskBuilder {
192118
self.stdout = Some(stdout);
193119
self
194120
}
195121

196122
/// Redirect task-local stderr.
197123
#[experimental = "May not want to make stdio overridable here."]
198-
pub fn stderr(mut self, stderr: Box<Writer + Send>) -> TaskBuilder<S> {
124+
pub fn stderr(mut self, stderr: Box<Writer + Send>) -> TaskBuilder {
199125
self.stderr = Some(stderr);
200126
self
201127
}
202128

203-
/// Set the spawning mechanism for the task.
204-
///
205-
/// The `TaskBuilder` API configures a task to be spawned, but defers to the
206-
/// "spawner" to actually create and spawn the task. The `spawner` method
207-
/// should not be called directly by `TaskBuiler` clients. It is intended
208-
/// for use by downstream crates (like `native` and `green`) that implement
209-
/// tasks. These downstream crates then add extension methods to the
210-
/// builder, like `.native()` and `.green(pool)`, that actually set the
211-
/// spawner.
212-
pub fn spawner<T: Spawner>(self, spawner: T) -> TaskBuilder<T> {
213-
// repackage the entire TaskBuilder since its type is changing.
214-
let TaskBuilder {
215-
name, stack_size, stdout, stderr, spawner: _, gen_body, nocopy
216-
} = self;
217-
TaskBuilder {
218-
name: name,
219-
stack_size: stack_size,
220-
stdout: stdout,
221-
stderr: stderr,
222-
spawner: spawner,
223-
gen_body: gen_body,
224-
nocopy: nocopy,
225-
}
226-
}
227-
228129
// Where spawning actually happens (whether yielding a future or not)
229130
fn spawn_internal(self, f: proc():Send,
230131
on_exit: Option<proc(Result<(), Box<Any + Send>>):Send>) {
231132
let TaskBuilder {
232-
name, stack_size, stdout, stderr, spawner, mut gen_body, nocopy: _
133+
name, stack_size, stdout, stderr, mut gen_body, nocopy: _
233134
} = self;
234135
let f = match gen_body.take() {
235136
Some(gen) => gen(f),
@@ -348,11 +249,8 @@ pub fn name() -> Option<String> {
348249
/// Yield control to the task scheduler.
349250
#[unstable = "Name will change."]
350251
pub fn deschedule() {
351-
use rt::local::Local;
352-
353-
// FIXME(#7544): Optimize this, since we know we won't block.
354-
let task: Box<Task> = Local::take();
355-
task.yield_now();
252+
use rt::task::Task;
253+
Task::yield_now();
356254
}
357255

358256
/// True if the running task is currently panicking (e.g. will return `true` inside a

0 commit comments

Comments
 (0)