Skip to content

Commit 8fafd5d

Browse files
steveklabnikManishearth
authored andcommitted
s/task/thread/g
A part of rust-lang#20038
1 parent db2d99e commit 8fafd5d

File tree

1 file changed

+51
-54
lines changed

1 file changed

+51
-54
lines changed

reference.md

Lines changed: 51 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -899,8 +899,8 @@ mirrors the module hierarchy.
899899
// Load the `vec` module from `vec.rs`
900900
mod vec;
901901
902-
mod task {
903-
// Load the `local_data` module from `task/local_data.rs`
902+
mod thread {
903+
// Load the `local_data` module from `thread/local_data.rs`
904904
mod local_data;
905905
}
906906
```
@@ -909,9 +909,9 @@ The directories and files used for loading external file modules can be
909909
influenced with the `path` attribute.
910910

911911
```{.ignore}
912-
#[path = "task_files"]
913-
mod task {
914-
// Load the `local_data` module from `task_files/tls.rs`
912+
#[path = "thread_files"]
913+
mod thread {
914+
// Load the `local_data` module from `thread_files/tls.rs`
915915
#[path = "tls.rs"]
916916
mod local_data;
917917
}
@@ -1188,7 +1188,7 @@ code safe, in the surrounding context.
11881188
Unsafe blocks are used to wrap foreign libraries, make direct use of hardware
11891189
or implement features not directly present in the language. For example, Rust
11901190
provides the language features necessary to implement memory-safe concurrency
1191-
in the language but the implementation of tasks and message passing is in the
1191+
in the language but the implementation of threads and message passing is in the
11921192
standard library.
11931193

11941194
Rust's type system is a conservative approximation of the dynamic safety
@@ -1500,7 +1500,7 @@ be modified by the program. One of Rust's goals is to make concurrency bugs
15001500
hard to run into, and this is obviously a very large source of race conditions
15011501
or other bugs. For this reason, an `unsafe` block is required when either
15021502
reading or writing a mutable static variable. Care should be taken to ensure
1503-
that modifications to a mutable static are safe with respect to other tasks
1503+
that modifications to a mutable static are safe with respect to other threads
15041504
running in the same process.
15051505

15061506
Mutable statics are still very useful, however. They can be used with C
@@ -2253,11 +2253,11 @@ A complete list of the built-in language items follows:
22532253
* `drop`
22542254
: Have destructors.
22552255
* `send`
2256-
: Able to be sent across task boundaries.
2256+
: Able to be sent across thread boundaries.
22572257
* `sized`
22582258
: Has a size known at compile time.
22592259
* `sync`
2260-
: Able to be safely shared between tasks when aliased.
2260+
: Able to be safely shared between threads when aliased.
22612261

22622262
#### Operators
22632263

@@ -2621,7 +2621,7 @@ The currently implemented features of the reference compiler are:
26212621
LLVM's implementation which works in concert with the kernel
26222622
loader and dynamic linker. This is not necessarily available
26232623
on all platforms, and usage of it is discouraged (rust
2624-
focuses more on task-local data instead of thread-local
2624+
focuses more on thread-local data instead of thread-local
26252625
data).
26262626

26272627
* `trace_macros` - Allows use of the `trace_macros` macro, which is a nasty
@@ -2939,7 +2939,7 @@ array is mutable, the resulting [lvalue](#lvalues,-rvalues-and-temporaries) can
29392939
be assigned to.
29402940

29412941
Indices are zero-based, and may be of any integral type. Vector access is
2942-
bounds-checked at run-time. When the check fails, it will put the task in a
2942+
bounds-checked at run-time. When the check fails, it will put the thread in a
29432943
_panicked state_.
29442944

29452945
```{should-fail}
@@ -3950,7 +3950,7 @@ Types in Rust are categorized into kinds, based on various properties of the
39503950
components of the type. The kinds are:
39513951

39523952
* `Send`
3953-
: Types of this kind can be safely sent between tasks.
3953+
: Types of this kind can be safely sent between threads.
39543954
This kind includes scalars, boxes, procs, and
39553955
structural types containing only other owned types.
39563956
All `Send` types are `'static`.
@@ -3998,21 +3998,21 @@ to sendable.
39983998

39993999
# Memory and concurrency models
40004000

4001-
Rust has a memory model centered around concurrently-executing _tasks_. Thus
4001+
Rust has a memory model centered around concurrently-executing _threads_. Thus
40024002
its memory model and its concurrency model are best discussed simultaneously,
40034003
as parts of each only make sense when considered from the perspective of the
40044004
other.
40054005

40064006
When reading about the memory model, keep in mind that it is partitioned in
4007-
order to support tasks; and when reading about tasks, keep in mind that their
4007+
order to support threads; and when reading about threads, keep in mind that their
40084008
isolation and communication mechanisms are only possible due to the ownership
40094009
and lifetime semantics of the memory model.
40104010

40114011
## Memory model
40124012

40134013
A Rust program's memory consists of a static set of *items*, a set of
4014-
[tasks](#tasks) each with its own *stack*, and a *heap*. Immutable portions of
4015-
the heap may be shared between tasks, mutable portions may not.
4014+
[threads](#threads) each with its own *stack*, and a *heap*. Immutable portions of
4015+
the heap may be shared between threads, mutable portions may not.
40164016

40174017
Allocations in the stack consist of *slots*, and allocations in the heap
40184018
consist of *boxes*.
@@ -4023,8 +4023,8 @@ The _items_ of a program are those functions, modules and types that have their
40234023
value calculated at compile-time and stored uniquely in the memory image of the
40244024
rust process. Items are neither dynamically allocated nor freed.
40254025

4026-
A task's _stack_ consists of activation frames automatically allocated on entry
4027-
to each function as the task executes. A stack allocation is reclaimed when
4026+
A thread's _stack_ consists of activation frames automatically allocated on entry
4027+
to each function as the thread executes. A stack allocation is reclaimed when
40284028
control leaves the frame containing it.
40294029

40304030
The _heap_ is a general term that describes boxes. The lifetime of an
@@ -4034,10 +4034,10 @@ in the heap, heap allocations may outlive the frame they are allocated within.
40344034

40354035
### Memory ownership
40364036

4037-
A task owns all memory it can *safely* reach through local variables, as well
4037+
A thread owns all memory it can *safely* reach through local variables, as well
40384038
as boxes and references.
40394039

4040-
When a task sends a value that has the `Send` trait to another task, it loses
4040+
When a thread sends a value that has the `Send` trait to another thread, it loses
40414041
ownership of the value sent and can no longer refer to it. This is statically
40424042
guaranteed by the combined use of "move semantics", and the compiler-checked
40434043
_meaning_ of the `Send` trait: it is only instantiated for (transitively)
@@ -4046,12 +4046,12 @@ sendable kinds of data constructor and pointers, never including references.
40464046
When a stack frame is exited, its local allocations are all released, and its
40474047
references to boxes are dropped.
40484048

4049-
When a task finishes, its stack is necessarily empty and it therefore has no
4049+
When a thread finishes, its stack is necessarily empty and it therefore has no
40504050
references to any boxes; the remainder of its heap is immediately freed.
40514051

40524052
### Memory slots
40534053

4054-
A task's stack contains slots.
4054+
A thread's stack contains slots.
40554055

40564056
A _slot_ is a component of a stack frame, either a function parameter, a
40574057
[temporary](#lvalues,-rvalues-and-temporaries), or a local variable.
@@ -4105,72 +4105,69 @@ let y = x;
41054105
// attempting to use `x` will result in an error here
41064106
```
41074107

4108-
## Tasks
4108+
## Threads
41094109

4110-
An executing Rust program consists of a tree of tasks. A Rust _task_ consists
4111-
of an entry function, a stack, a set of outgoing communication channels and
4112-
incoming communication ports, and ownership of some portion of the heap of a
4113-
single operating-system process.
4110+
Rust's primary concurrency mechanism is called a **thread**.
41144111

4115-
### Communication between tasks
4112+
### Communication between threads
41164113

4117-
Rust tasks are isolated and generally unable to interfere with one another's
4114+
Rust threads are isolated and generally unable to interfere with one another's
41184115
memory directly, except through [`unsafe` code](#unsafe-functions). All
4119-
contact between tasks is mediated by safe forms of ownership transfer, and data
4116+
contact between threads is mediated by safe forms of ownership transfer, and data
41204117
races on memory are prohibited by the type system.
41214118

4122-
When you wish to send data between tasks, the values are restricted to the
4119+
When you wish to send data between threads, the values are restricted to the
41234120
[`Send` type-kind](#type-kinds). Restricting communication interfaces to this
4124-
kind ensures that no references move between tasks. Thus access to an entire
4121+
kind ensures that no references move between threads. Thus access to an entire
41254122
data structure can be mediated through its owning "root" value; no further
41264123
locking or copying is required to avoid data races within the substructure of
41274124
such a value.
41284125

4129-
### Task lifecycle
4126+
### Thread
41304127

4131-
The _lifecycle_ of a task consists of a finite set of states and events that
4132-
cause transitions between the states. The lifecycle states of a task are:
4128+
The _lifecycle_ of a threads consists of a finite set of states and events that
4129+
cause transitions between the states. The lifecycle states of a thread are:
41334130

41344131
* running
41354132
* blocked
41364133
* panicked
41374134
* dead
41384135

4139-
A task begins its lifecycle — once it has been spawned — in the
4136+
A thread begins its lifecycle — once it has been spawned — in the
41404137
*running* state. In this state it executes the statements of its entry
41414138
function, and any functions called by the entry function.
41424139

4143-
A task may transition from the *running* state to the *blocked* state any time
4140+
A thread may transition from the *running* state to the *blocked* state any time
41444141
it makes a blocking communication call. When the call can be completed —
41454142
when a message arrives at a sender, or a buffer opens to receive a message
4146-
— then the blocked task will unblock and transition back to *running*.
4143+
— then the blocked thread will unblock and transition back to *running*.
41474144

4148-
A task may transition to the *panicked* state at any time, due being killed by
4145+
A thread may transition to the *panicked* state at any time, due being killed by
41494146
some external event or internally, from the evaluation of a `panic!()` macro.
4150-
Once *panicking*, a task unwinds its stack and transitions to the *dead* state.
4151-
Unwinding the stack of a task is done by the task itself, on its own control
4147+
Once *panicking*, a thread unwinds its stack and transitions to the *dead* state.
4148+
Unwinding the stack of a thread is done by the thread itself, on its own control
41524149
stack. If a value with a destructor is freed during unwinding, the code for the
4153-
destructor is run, also on the task's control stack. Running the destructor
4150+
destructor is run, also on the thread's control stack. Running the destructor
41544151
code causes a temporary transition to a *running* state, and allows the
4155-
destructor code to cause any subsequent state transitions. The original task
4152+
destructor code to cause any subsequent state transitions. The original thread
41564153
of unwinding and panicking thereby may suspend temporarily, and may involve
41574154
(recursive) unwinding of the stack of a failed destructor. Nonetheless, the
41584155
outermost unwinding activity will continue until the stack is unwound and the
4159-
task transitions to the *dead* state. There is no way to "recover" from task
4160-
panics. Once a task has temporarily suspended its unwinding in the *panicking*
4156+
thread transitions to the *dead* state. There is no way to "recover" from thread
4157+
panics. Once a thread has temporarily suspended its unwinding in the *panicking*
41614158
state, a panic occurring from within this destructor results in *hard* panic.
41624159
A hard panic currently results in the process aborting.
41634160

4164-
A task in the *dead* state cannot transition to other states; it exists only to
4165-
have its termination status inspected by other tasks, and/or to await
4161+
A thread in the *dead* state cannot transition to other states; it exists only to
4162+
have its termination status inspected by other threads, and/or to await
41664163
reclamation when the last reference to it drops.
41674164

41684165
# Runtime services, linkage and debugging
41694166

41704167
The Rust _runtime_ is a relatively compact collection of Rust code that
4171-
provides fundamental services and datatypes to all Rust tasks at run-time. It
4168+
provides fundamental services and datatypes to all Rust threads at run-time. It
41724169
is smaller and simpler than many modern language runtimes. It is tightly
4173-
integrated into the language's execution model of memory, tasks, communication
4170+
integrated into the language's execution model of memory, threads, communication
41744171
and logging.
41754172

41764173
### Memory allocation
@@ -4181,23 +4178,23 @@ environment and releases them back to its environment when they are no longer
41814178
needed. The default implementation of the service-provider interface consists
41824179
of the C runtime functions `malloc` and `free`.
41834180

4184-
The runtime memory-management system, in turn, supplies Rust tasks with
4181+
The runtime memory-management system, in turn, supplies Rust threads with
41854182
facilities for allocating releasing stacks, as well as allocating and freeing
41864183
heap data.
41874184

41884185
### Built in types
41894186

41904187
The runtime provides C and Rust code to assist with various built-in types,
41914188
such as arrays, strings, and the low level communication system (ports,
4192-
channels, tasks).
4189+
channels, threads).
41934190

41944191
Support for other built-in types such as simple types, tuples and enums is
41954192
open-coded by the Rust compiler.
41964193

4197-
### Task scheduling and communication
4194+
### Thread scheduling and communication
41984195

4199-
The runtime provides code to manage inter-task communication. This includes
4200-
the system of task-lifecycle state transitions depending on the contents of
4196+
The runtime provides code to manage inter-thread communication. This includes
4197+
the system of thread-lifecycle state transitions depending on the contents of
42014198
queues, as well as code to copy values between queues and their recipients and
42024199
to serialize values for transmission over operating-system inter-process
42034200
communication facilities.

0 commit comments

Comments
 (0)