Skip to content

Add Clone implementations for managed and managed mutable types. #5750

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 54 commits into from
Closed
Changes from 1 commit
Commits
Show all changes
54 commits
Select commit Hold shift + click to select a range
2b07f0f
field renaming
jbclements Mar 12, 2013
556143c
commenting parser
jbclements Mar 8, 2013
f2e47cd
change to parsing using tts
jbclements Mar 6, 2013
a20d1ad
Improve documentation for core::io.
steveklabnik Apr 1, 2013
1d658d9
Improve docs for Core::ReaderUtil.
steveklabnik Apr 2, 2013
948ff60
Typo fix. u8 -> i8
steveklabnik Apr 2, 2013
88e4b5d
install the librust{doc,pkg} host libraries
thestinger Apr 2, 2013
86d5ce5
remove trailing whitespace
steveklabnik Apr 3, 2013
a3e2d6e
Remove excess trailing whitespace.
steveklabnik Apr 3, 2013
e4edfa0
libstd: implement fileinput.
huonw Feb 23, 2013
1e28d8f
libstd: implement io::Reader for fileinput.
huonw Mar 25, 2013
f357a03
auto merge of #5685 : thestinger/rust/build, r=graydon
bors Apr 3, 2013
fea1380
libstd: make fileinput tests pass.
huonw Apr 3, 2013
cb16cd9
auto merge of #5673 : steveklabnik/rust/improve_io_docs, r=catamorphism
bors Apr 3, 2013
26d8b51
auto merge of #5674 : steveklabnik/rust/improve_reader_util_docs, r=c…
bors Apr 3, 2013
0cc9030
auto merge of #5202 : dbaupp/rust/std-fileinput, r=graydon
bors Apr 3, 2013
e2bffb7
Implement Clone for tuples
Apr 3, 2013
afd5cba
auto merge of #5692 : Aatch/rust/tuple-clone, r=thestinger
bors Apr 3, 2013
84e5033
Make bench/noise.rs more idiomatic and 20x faster
bstrie Apr 3, 2013
260d74d
auto merge of #5695 : bstrie/rust/noise, r=thestinger
bors Apr 3, 2013
44029a5
hashmap: rm linear namespace
thestinger Apr 3, 2013
cc148b5
rename Linear{Map,Set} => Hash{Map,Set}
thestinger Apr 3, 2013
c16919d
Removing mut fields from vec.rs, at_vec.rs, str.rs, unstable.rs, and …
Thiez Apr 2, 2013
397a478
Unstable didn't need transmute_mut after all.
Thiez Apr 3, 2013
c4d2b79
Add Clone derivation for std::net::url types.
metajack Apr 3, 2013
6153aae
auto merge of #5559 : jbclements/rust/change-to-tt-based-parsing, r=j…
bors Apr 3, 2013
d79b224
Add information about logging macros to the tutorial.
steveklabnik Apr 3, 2013
34b2336
Fix compiletest on windows
brson Apr 3, 2013
3044f5e
typo fix: na -> an
steveklabnik Apr 3, 2013
5b933ae
auto merge of #5696 : thestinger/rust/hashmap, r=sanxiyn
bors Apr 3, 2013
8dd5a70
Update tut. to not sound like I missed a section
brettcannon Apr 3, 2013
17ab718
auto merge of #5698 : Thiez/rust/de-mutfielding, r=pcwalton
bors Apr 3, 2013
84c296b
auto merge of #5701 : metajack/rust/net-url-clone, r=thestinger
bors Apr 3, 2013
a7f0bfb
One more typo: dubug -> debug
steveklabnik Apr 3, 2013
e2c7a4d
Simple typo fix
ajuckel Apr 4, 2013
783392f
auto merge of #5704 : brson/rust/compiletest, r=luqmana
bors Apr 4, 2013
f064048
Remove a android hack
ILyoan Apr 3, 2013
fac0d9d
Decides main name by target
ILyoan Apr 3, 2013
53232f7
Fix fileinput test fail
ILyoan Apr 4, 2013
af1baa3
auto merge of #5691 : ILyoan/rust/main_name, r=thestinger
bors Apr 4, 2013
aa899c9
auto merge of #5710 : ajuckel/rust/patch-1, r=luqmana
bors Apr 4, 2013
679b1dc
doc: Rewrite task tutorial intro
brson Apr 4, 2013
21de574
auto merge of #5703 : steveklabnik/rust/add_log_docs, r=thestinger
bors Apr 4, 2013
1dc330c
auto merge of #5707 : brettcannon/rust/patch-1, r=thestinger
bors Apr 4, 2013
b5d8224
auto merge of #5713 : brson/rust/tutorial2, r=thestinger
bors Apr 4, 2013
99b156e
mk: mips toolchain config
crabtw Mar 19, 2013
fdf48a7
rt: improve mips backend
crabtw Mar 19, 2013
4f1d8cb
fix mac build and comment on stack size check
crabtw Mar 29, 2013
cb91e91
Tutorial: rename variable to avoid confusion.
Apr 4, 2013
717ed51
auto merge of #5716 : dhardy/rust/master, r=thestinger
bors Apr 4, 2013
2c02aab
Add cell#with_mut_ref for handling mutable references to the content.
metajack Apr 4, 2013
c08fb75
auto merge of #5431 : crabtw/rust/mips-rt, r=brson
bors Apr 4, 2013
babe506
auto merge of #5722 : metajack/rust/cell-with-ref-mut, r=catamorphism
bors Apr 5, 2013
b22a060
Implement Clone for @ and @mut types.
metajack Apr 5, 2013
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
doc: Rewrite task tutorial intro
It doesn't quite reflect reality
  • Loading branch information
brson committed Apr 4, 2013
commit 679b1dcb62b53f52f6e4ffe18cc89be8dbf5cc15
67 changes: 28 additions & 39 deletions doc/tutorial-tasks.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,74 +2,63 @@

# Introduction

The designers of Rust designed the language from the ground up to support pervasive
and safe concurrency through lightweight, memory-isolated tasks and
message passing.

Rust tasks are not the same as traditional threads: rather, they are more like
_green threads_. The Rust runtime system schedules tasks cooperatively onto a
small number of operating system threads. Because tasks are significantly
Rust provides safe concurrency through a combination
of lightweight, memory-isolated tasks and message passing.
This tutorial will describe the concurrency model in Rust, how it
relates to the Rust type system, and introduce
the fundamental library abstractions for constructing concurrent programs.

Rust tasks are not the same as traditional threads: rather,
they are considered _green threads_, lightweight units of execution that the Rust
runtime schedules cooperatively onto a small number of operating system threads.
On a multi-core system Rust tasks will be scheduled in parallel by default.
Because tasks are significantly
cheaper to create than traditional threads, Rust can create hundreds of
thousands of concurrent tasks on a typical 32-bit system.
In general, all Rust code executes inside a task, including the `main` function.

In order to make efficient use of memory Rust tasks have dynamically sized stacks.
A task begins its life with a small
amount of stack space (currently in the low thousands of bytes, depending on
platform), and acquires more stack as needed.
Unlike in languages such as C, a Rust task cannot accidentally write to
memory beyond the end of the stack, causing crashes or worse.

Tasks provide failure isolation and recovery. When an exception occurs in Rust
code (as a result of an explicit call to `fail!()`, an assertion failure, or
another invalid operation), the runtime system destroys the entire
Tasks provide failure isolation and recovery. When a fatal error occurs in Rust
code as a result of an explicit call to `fail!()`, an assertion failure, or
another invalid operation, the runtime system destroys the entire
task. Unlike in languages such as Java and C++, there is no way to `catch` an
exception. Instead, tasks may monitor each other for failure.

Rust tasks have dynamically sized stacks. A task begins its life with a small
amount of stack space (currently in the low thousands of bytes, depending on
platform), and acquires more stack as needed. Unlike in languages such as C, a
Rust task cannot run off the end of the stack. However, tasks do have a stack
budget. If a Rust task exceeds its stack budget, then it will fail safely:
with a checked exception.

Tasks use Rust's type system to provide strong memory safety guarantees. In
particular, the type system guarantees that tasks cannot share mutable state
with each other. Tasks communicate with each other by transferring _owned_
data through the global _exchange heap_.

This tutorial explains the basics of tasks and communication in Rust,
explores some typical patterns in concurrent Rust code, and finally
discusses some of the more unusual synchronization types in the standard
library.

> ***Warning:*** This tutorial is incomplete

## A note about the libraries

While Rust's type system provides the building blocks needed for safe
and efficient tasks, all of the task functionality itself is implemented
in the core and standard libraries, which are still under development
and do not always present a consistent interface.

In particular, there are currently two independent modules that provide a
message passing interface to Rust code: `core::comm` and `core::pipes`.
`core::comm` is an older, less efficient system that is being phased out in
favor of `pipes`. At some point, we will remove the existing `core::comm` API
and move the user-facing portions of `core::pipes` to `core::comm`. In this
tutorial, we discuss `pipes` and ignore the `comm` API.
and do not always present a consistent or complete interface.

For your reference, these are the standard modules involved in Rust
concurrency at this writing.

* [`core::task`] - All code relating to tasks and task scheduling
* [`core::comm`] - The deprecated message passing API
* [`core::pipes`] - The new message passing infrastructure and API
* [`std::comm`] - Higher level messaging types based on `core::pipes`
* [`core::comm`] - The message passing interface
* [`core::pipes`] - The underlying messaging infrastructure
* [`std::comm`] - Additional messaging types based on `core::pipes`
* [`std::sync`] - More exotic synchronization tools, including locks
* [`std::arc`] - The ARC (atomic reference counted) type, for safely sharing
immutable data
* [`std::par`] - Some basic tools for implementing parallel algorithms
* [`std::arc`] - The ARC (atomically reference counted) type,
for safely sharing immutable data

[`core::task`]: core/task.html
[`core::comm`]: core/comm.html
[`core::pipes`]: core/pipes.html
[`std::comm`]: std/comm.html
[`std::sync`]: std/sync.html
[`std::arc`]: std/arc.html
[`std::par`]: std/par.html

# Basics

Expand Down