Skip to content

Commit 79b8a69

Browse files
committed
Merge pull request #25309 from barosl/no-more-tasks
Backport `task` -> `thread` to beta
2 parents 8421c7c + 59fe5e5 commit 79b8a69

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

75 files changed

+200
-199
lines changed

src/compiletest/compiletest.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -226,15 +226,15 @@ pub fn run_tests(config: &Config) {
226226
}
227227

228228
// android debug-info test uses remote debugger
229-
// so, we test 1 task at once.
229+
// so, we test 1 thread at once.
230230
// also trying to isolate problems with adb_run_wrapper.sh ilooping
231231
env::set_var("RUST_TEST_THREADS","1");
232232
}
233233

234234
match config.mode {
235235
DebugInfoLldb => {
236236
// Some older versions of LLDB seem to have problems with multiple
237-
// instances running in parallel, so only run one test task at a
237+
// instances running in parallel, so only run one test thread at a
238238
// time.
239239
env::set_var("RUST_TEST_THREADS", "1");
240240
}

src/doc/complement-design-faq.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ code should need to run is a stack.
9696
possibility is covered by the `match`, adding further variants to the `enum`
9797
in the future will prompt a compilation failure, rather than runtime panic.
9898
Second, it makes cost explicit. In general, the only safe way to have a
99-
non-exhaustive match would be to panic the task if nothing is matched, though
99+
non-exhaustive match would be to panic the thread if nothing is matched, though
100100
it could fall through if the type of the `match` expression is `()`. This sort
101101
of hidden cost and special casing is against the language's philosophy. It's
102102
easy to ignore certain cases by using the `_` wildcard:

src/doc/complement-lang-faq.md

+6-6
Original file line numberDiff line numberDiff line change
@@ -62,15 +62,15 @@ Data values in the language can only be constructed through a fixed set of initi
6262
* There is no global inter-crate namespace; all name management occurs within a crate.
6363
* Using another crate binds the root of _its_ namespace into the user's namespace.
6464

65-
## Why is panic unwinding non-recoverable within a task? Why not try to "catch exceptions"?
65+
## Why is panic unwinding non-recoverable within a thread? Why not try to "catch exceptions"?
6666

67-
In short, because too few guarantees could be made about the dynamic environment of the catch block, as well as invariants holding in the unwound heap, to be able to safely resume; we believe that other methods of signalling and logging errors are more appropriate, with tasks playing the role of a "hard" isolation boundary between separate heaps.
67+
In short, because too few guarantees could be made about the dynamic environment of the catch block, as well as invariants holding in the unwound heap, to be able to safely resume; we believe that other methods of signalling and logging errors are more appropriate, with threads playing the role of a "hard" isolation boundary between separate heaps.
6868

6969
Rust provides, instead, three predictable and well-defined options for handling any combination of the three main categories of "catch" logic:
7070

7171
* Failure _logging_ is done by the integrated logging subsystem.
72-
* _Recovery_ after a panic is done by trapping a task panic from _outside_
73-
the task, where other tasks are known to be unaffected.
72+
* _Recovery_ after a panic is done by trapping a thread panic from _outside_
73+
the thread, where other threads are known to be unaffected.
7474
* _Cleanup_ of resources is done by RAII-style objects with destructors.
7575

7676
Cleanup through RAII-style destructors is more likely to work than in catch blocks anyways, since it will be better tested (part of the non-error control paths, so executed all the time).
@@ -91,8 +91,8 @@ We don't know if there's an obvious, easy, efficient, stock-textbook way of supp
9191

9292
There's a lot of debate on this topic; it's easy to find a proponent of default-sync or default-async communication, and there are good reasons for either. Our choice rests on the following arguments:
9393

94-
* Part of the point of isolating tasks is to decouple tasks from one another, such that assumptions in one task do not cause undue constraints (or bugs, if violated!) in another. Temporal coupling is as real as any other kind; async-by-default relaxes the default case to only _causal_ coupling.
95-
* Default-async supports buffering and batching communication, reducing the frequency and severity of task-switching and inter-task / inter-domain synchronization.
94+
* Part of the point of isolating threads is to decouple threads from one another, such that assumptions in one thread do not cause undue constraints (or bugs, if violated!) in another. Temporal coupling is as real as any other kind; async-by-default relaxes the default case to only _causal_ coupling.
95+
* Default-async supports buffering and batching communication, reducing the frequency and severity of thread-switching and inter-thread / inter-domain synchronization.
9696
* Default-async with transmittable channels is the lowest-level building block on which more-complex synchronization topologies and strategies can be built; it is not clear to us that the majority of cases fit the 2-party full-synchronization pattern rather than some more complex multi-party or multi-stage scenario. We did not want to force all programs to pay for wiring the former assumption into all communications.
9797

9898
## Why are channels half-duplex (one-way)?

src/doc/grammar.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -767,8 +767,8 @@ bound := path | lifetime
767767

768768
### Boxes
769769

770-
## Tasks
770+
## Threads
771771

772-
### Communication between tasks
772+
### Communication between threads
773773

774-
### Task lifecycle
774+
### Thread lifecycle

src/doc/reference.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -4057,7 +4057,7 @@ that have since been removed):
40574057
* ML Kit, Cyclone: region based memory management
40584058
* Haskell (GHC): typeclasses, type families
40594059
* Newsqueak, Alef, Limbo: channels, concurrency
4060-
* Erlang: message passing, task failure, ~~linked task failure~~,
4060+
* Erlang: message passing, thread failure, ~~linked thread failure~~,
40614061
~~lightweight concurrency~~
40624062
* Swift: optional bindings
40634063
* Scheme: hygienic macros

src/doc/style/errors/handling.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
% Handling errors
22

3-
### Use task isolation to cope with failure. [FIXME]
3+
### Use thread isolation to cope with failure. [FIXME]
44

5-
> **[FIXME]** Explain how to isolate tasks and detect task failure for recovery.
5+
> **[FIXME]** Explain how to isolate threads and detect thread failure for recovery.
66
77
### Consuming `Result` [FIXME]

src/doc/style/errors/signaling.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,13 @@ Errors fall into one of three categories:
1111
The basic principle of the convention is that:
1212

1313
* Catastrophic errors and programming errors (bugs) can and should only be
14-
recovered at a *coarse grain*, i.e. a task boundary.
14+
recovered at a *coarse grain*, i.e. a thread boundary.
1515
* Obstructions preventing an operation should be reported at a maximally *fine
1616
grain* -- to the immediate invoker of the operation.
1717

1818
## Catastrophic errors
1919

20-
An error is _catastrophic_ if there is no meaningful way for the current task to
20+
An error is _catastrophic_ if there is no meaningful way for the current thread to
2121
continue after the error occurs.
2222

2323
Catastrophic errors are _extremely_ rare, especially outside of `libstd`.
@@ -28,7 +28,7 @@ Catastrophic errors are _extremely_ rare, especially outside of `libstd`.
2828

2929
For errors like stack overflow, Rust currently aborts the process, but
3030
could in principle panic, which (in the best case) would allow
31-
reporting and recovery from a supervisory task.
31+
reporting and recovery from a supervisory thread.
3232

3333
## Contract violations
3434

@@ -44,7 +44,7 @@ existing borrows have been relinquished.
4444

4545
A contract violation is always a bug, and for bugs we follow the Erlang
4646
philosophy of "let it crash": we assume that software *will* have bugs, and we
47-
design coarse-grained task boundaries to report, and perhaps recover, from these
47+
design coarse-grained thread boundaries to report, and perhaps recover, from these
4848
bugs.
4949

5050
### Contract design

src/doc/style/ownership/builders.md

+14-14
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ If `T` is such a data structure, consider introducing a `T` _builder_:
2323
4. The builder should provide one or more "_terminal_" methods for actually building a `T`.
2424

2525
The builder pattern is especially appropriate when building a `T` involves side
26-
effects, such as spawning a task or launching a process.
26+
effects, such as spawning a thread or launching a process.
2727

2828
In Rust, there are two variants of the builder pattern, differing in the
2929
treatment of ownership, as described below.
@@ -115,24 +115,24 @@ Sometimes builders must transfer ownership when constructing the final type
115115
`T`, meaning that the terminal methods must take `self` rather than `&self`:
116116

117117
```rust
118-
// A simplified excerpt from std::task::TaskBuilder
118+
// A simplified excerpt from std::thread::Builder
119119

120-
impl TaskBuilder {
121-
/// Name the task-to-be. Currently the name is used for identification
120+
impl ThreadBuilder {
121+
/// Name the thread-to-be. Currently the name is used for identification
122122
/// only in failure messages.
123-
pub fn named(mut self, name: String) -> TaskBuilder {
123+
pub fn named(mut self, name: String) -> ThreadBuilder {
124124
self.name = Some(name);
125125
self
126126
}
127127

128-
/// Redirect task-local stdout.
129-
pub fn stdout(mut self, stdout: Box<Writer + Send>) -> TaskBuilder {
128+
/// Redirect thread-local stdout.
129+
pub fn stdout(mut self, stdout: Box<Writer + Send>) -> ThreadBuilder {
130130
self.stdout = Some(stdout);
131131
// ^~~~~~ this is owned and cannot be cloned/re-used
132132
self
133133
}
134134

135-
/// Creates and executes a new child task.
135+
/// Creates and executes a new child thread.
136136
pub fn spawn(self, f: proc():Send) {
137137
// consume self
138138
...
@@ -141,7 +141,7 @@ impl TaskBuilder {
141141
```
142142

143143
Here, the `stdout` configuration involves passing ownership of a `Writer`,
144-
which must be transferred to the task upon construction (in `spawn`).
144+
which must be transferred to the thread upon construction (in `spawn`).
145145

146146
When the terminal methods of the builder require ownership, there is a basic tradeoff:
147147

@@ -158,17 +158,17 @@ builder methods for a consuming builder should take and returned an owned
158158

159159
```rust
160160
// One-liners
161-
TaskBuilder::new().named("my_task").spawn(proc() { ... });
161+
ThreadBuilder::new().named("my_thread").spawn(proc() { ... });
162162

163163
// Complex configuration
164-
let mut task = TaskBuilder::new();
165-
task = task.named("my_task_2"); // must re-assign to retain ownership
164+
let mut thread = ThreadBuilder::new();
165+
thread = thread.named("my_thread_2"); // must re-assign to retain ownership
166166

167167
if reroute {
168-
task = task.stdout(mywriter);
168+
thread = thread.stdout(mywriter);
169169
}
170170

171-
task.spawn(proc() { ... });
171+
thread.spawn(proc() { ... });
172172
```
173173

174174
One-liners work as before, because ownership is threaded through each of the

src/doc/style/ownership/destructors.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ go out of scope.
88
99
### Destructors should not fail. [FIXME: needs RFC]
1010

11-
Destructors are executed on task failure, and in that context a failing
11+
Destructors are executed on thread failure, and in that context a failing
1212
destructor causes the program to abort.
1313

1414
Instead of failing in a destructor, provide a separate method for checking for

src/doc/style/style/comments.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,15 @@
55
Use line comments:
66

77
``` rust
8-
// Wait for the main task to return, and set the process error code
8+
// Wait for the main thread to return, and set the process error code
99
// appropriately.
1010
```
1111

1212
Instead of:
1313

1414
``` rust
1515
/*
16-
* Wait for the main task to return, and set the process error code
16+
* Wait for the main thread to return, and set the process error code
1717
* appropriately.
1818
*/
1919
```
@@ -55,7 +55,7 @@ For example:
5555
/// Sets up a default runtime configuration, given compiler-supplied arguments.
5656
///
5757
/// This function will block until the entire pool of M:N schedulers has
58-
/// exited. This function also requires a local task to be available.
58+
/// exited. This function also requires a local thread to be available.
5959
///
6060
/// # Arguments
6161
///
@@ -64,7 +64,7 @@ For example:
6464
/// * `main` - The initial procedure to run inside of the M:N scheduling pool.
6565
/// Once this procedure exits, the scheduling pool will begin to shut
6666
/// down. The entire pool (and this function) will only return once
67-
/// all child tasks have finished executing.
67+
/// all child threads have finished executing.
6868
///
6969
/// # Return value
7070
///

src/doc/style/style/naming/containers.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ they enclose. Accessor methods often have variants to access the data
55
by value, by reference, and by mutable reference.
66

77
In general, the `get` family of methods is used to access contained
8-
data without any risk of task failure; they return `Option` as
8+
data without any risk of thread failure; they return `Option` as
99
appropriate. This name is chosen rather than names like `find` or
1010
`lookup` because it is appropriate for a wider range of container types.
1111

src/doc/trpl/concurrency.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ and more cores, yet many programmers aren't prepared to fully utilize them.
66

77
Rust's memory safety features also apply to its concurrency story too. Even
88
concurrent Rust programs must be memory safe, having no data races. Rust's type
9-
system is up to the task, and gives you powerful ways to reason about
9+
system is up to the thread, and gives you powerful ways to reason about
1010
concurrent code at compile time.
1111

1212
Before we talk about the concurrency features that come with Rust, it's important

src/doc/trpl/iterators.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ loop is just a handy way to write this `loop`/`match`/`break` construct.
4242
`for` loops aren't the only thing that uses iterators, however. Writing your
4343
own iterator involves implementing the `Iterator` trait. While doing that is
4444
outside of the scope of this guide, Rust provides a number of useful iterators
45-
to accomplish various tasks. Before we talk about those, we should talk about a
45+
to accomplish various threads. Before we talk about those, we should talk about a
4646
Rust anti-pattern. And that's using ranges like this.
4747

4848
Yes, we just talked about how ranges are cool. But ranges are also very

src/liballoc/arc.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
//!
3232
//! # Examples
3333
//!
34-
//! Sharing some immutable data between tasks:
34+
//! Sharing some immutable data between threads:
3535
//!
3636
//! ```no_run
3737
//! use std::sync::Arc;
@@ -48,7 +48,7 @@
4848
//! }
4949
//! ```
5050
//!
51-
//! Sharing mutable data safely between tasks with a `Mutex`:
51+
//! Sharing mutable data safely between threads with a `Mutex`:
5252
//!
5353
//! ```no_run
5454
//! use std::sync::{Arc, Mutex};
@@ -89,9 +89,9 @@ use heap::deallocate;
8989
///
9090
/// # Examples
9191
///
92-
/// In this example, a large vector of floats is shared between several tasks.
92+
/// In this example, a large vector of floats is shared between several threads.
9393
/// With simple pipes, without `Arc`, a copy would have to be made for each
94-
/// task.
94+
/// thread.
9595
///
9696
/// When you clone an `Arc<T>`, it will create another pointer to the data and
9797
/// increase the reference counter.

src/liballoc/lib.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,14 @@
2626
//! There can only be one owner of a `Box`, and the owner can decide to mutate
2727
//! the contents, which live on the heap.
2828
//!
29-
//! This type can be sent among tasks efficiently as the size of a `Box` value
29+
//! This type can be sent among threads efficiently as the size of a `Box` value
3030
//! is the same as that of a pointer. Tree-like data structures are often built
3131
//! with boxes because each node often has only one owner, the parent.
3232
//!
3333
//! ## Reference counted pointers
3434
//!
3535
//! The [`Rc`](rc/index.html) type is a non-threadsafe reference-counted pointer
36-
//! type intended for sharing memory within a task. An `Rc` pointer wraps a
36+
//! type intended for sharing memory within a thread. An `Rc` pointer wraps a
3737
//! type, `T`, and only allows access to `&T`, a shared reference.
3838
//!
3939
//! This type is useful when inherited mutability (such as using `Box`) is too

src/libcore/atomic.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -52,20 +52,20 @@
5252
//! spinlock_clone.store(0, Ordering::SeqCst);
5353
//! });
5454
//!
55-
//! // Wait for the other task to release the lock
55+
//! // Wait for the other thread to release the lock
5656
//! while spinlock.load(Ordering::SeqCst) != 0 {}
5757
//! }
5858
//! ```
5959
//!
60-
//! Keep a global count of live tasks:
60+
//! Keep a global count of live threads:
6161
//!
6262
//! ```
6363
//! use std::sync::atomic::{AtomicUsize, Ordering, ATOMIC_USIZE_INIT};
6464
//!
65-
//! static GLOBAL_TASK_COUNT: AtomicUsize = ATOMIC_USIZE_INIT;
65+
//! static GLOBAL_THREAD_COUNT: AtomicUsize = ATOMIC_USIZE_INIT;
6666
//!
67-
//! let old_task_count = GLOBAL_TASK_COUNT.fetch_add(1, Ordering::SeqCst);
68-
//! println!("live tasks: {}", old_task_count + 1);
67+
//! let old_thread_count = GLOBAL_THREAD_COUNT.fetch_add(1, Ordering::SeqCst);
68+
//! println!("live threads: {}", old_thread_count + 1);
6969
//! ```
7070
7171
#![stable(feature = "rust1", since = "1.0.0")]

src/libcore/cell.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@
2424
//! claim temporary, exclusive, mutable access to the inner value. Borrows for `RefCell<T>`s are
2525
//! tracked 'at runtime', unlike Rust's native reference types which are entirely tracked
2626
//! statically, at compile time. Because `RefCell<T>` borrows are dynamic it is possible to attempt
27-
//! to borrow a value that is already mutably borrowed; when this happens it results in task panic.
27+
//! to borrow a value that is already mutably borrowed; when this happens it results in thread
28+
//! panic.
2829
//!
2930
//! # When to choose interior mutability
3031
//!
@@ -100,7 +101,7 @@
100101
//! // Recursive call to return the just-cached value.
101102
//! // Note that if we had not let the previous borrow
102103
//! // of the cache fall out of scope then the subsequent
103-
//! // recursive borrow would cause a dynamic task panic.
104+
//! // recursive borrow would cause a dynamic thread panic.
104105
//! // This is the major hazard of using `RefCell`.
105106
//! self.minimum_spanning_tree()
106107
//! }

src/libcore/macros.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
/// Entry point of task panic, for details, see std::macros
11+
/// Entry point of thread panic, for details, see std::macros
1212
#[macro_export]
1313
macro_rules! panic {
1414
() => (

src/liblog/lib.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ thread_local! {
228228
}
229229
}
230230

231-
/// A trait used to represent an interface to a task-local logger. Each task
231+
/// A trait used to represent an interface to a thread-local logger. Each thread
232232
/// can have its own custom logger which can respond to logging messages
233233
/// however it likes.
234234
pub trait Logger {
@@ -324,7 +324,7 @@ pub fn log(level: u32, loc: &'static LogLocation, args: fmt::Arguments) {
324324
#[inline(always)]
325325
pub fn log_level() -> u32 { unsafe { LOG_LEVEL } }
326326

327-
/// Replaces the task-local logger with the specified logger, returning the old
327+
/// Replaces the thread-local logger with the specified logger, returning the old
328328
/// logger.
329329
pub fn set_logger(logger: Box<Logger + Send>) -> Option<Box<Logger + Send>> {
330330
let mut l = Some(logger);

src/librustc/middle/ty.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -4482,7 +4482,7 @@ pub fn expr_ty_opt<'tcx>(cx: &ctxt<'tcx>, expr: &ast::Expr) -> Option<Ty<'tcx>>
44824482
/// require serializing and deserializing the type and, although that's not
44834483
/// hard to do, I just hate that code so much I didn't want to touch it
44844484
/// unless it was to fix it properly, which seemed a distraction from the
4485-
/// task at hand! -nmatsakis
4485+
/// thread at hand! -nmatsakis
44864486
pub fn expr_ty_adjusted<'tcx>(cx: &ctxt<'tcx>, expr: &ast::Expr) -> Ty<'tcx> {
44874487
adjust_ty(cx, expr.span, expr.id, expr_ty(cx, expr),
44884488
cx.adjustments.borrow().get(&expr.id),

0 commit comments

Comments
 (0)