Skip to content

Commit 2b74362

Browse files
committed
---
yaml --- r: 207705 b: refs/heads/tmp c: 5dc03a8 h: refs/heads/master i: 207703: 20d80c5 v: v3
1 parent 04b974b commit 2b74362

File tree

18 files changed

+259
-302
lines changed

18 files changed

+259
-302
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ refs/heads/building: 126db549b038c84269a1e4fe46f051b2c15d6970
3232
refs/heads/beta: cd7d89af9169885642d43597302af69f842bbd78
3333
refs/heads/windistfix: 7608dbad651f02e837ed05eef3d74a6662a6e928
3434
refs/tags/1.0.0-alpha: e42bd6d93a1d3433c486200587f8f9e12590a4d7
35-
refs/heads/tmp: e510eecf9fda5d4fc56bc5659355fc20fe68a7b8
35+
refs/heads/tmp: 5dc03a8246e76e9e3900d98f2f5d2574abaeaa6b
3636
refs/tags/1.0.0-alpha.2: 4c705f6bc559886632d3871b04f58aab093bfa2f
3737
refs/tags/homu-tmp: 704c2ee730d2e948d11a2edd77e3f35de8329a6e
3838
refs/heads/gate: 97c84447b65164731087ea82685580cc81424412

branches/tmp/src/doc/trpl/dining-philosophers.md

Lines changed: 42 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -2,28 +2,26 @@
22

33
For our second project, let’s look at a classic concurrency problem. It’s
44
called ‘the dining philosophers’. It was originally conceived by Dijkstra in
5-
1965, but we’ll use a lightly adapted version from [this paper][paper] by Tony
6-
Hoare in 1985.
5+
1965, but we’ll use the version from [this paper][paper] by Tony Hoare in 1985.
76

87
[paper]: http://www.usingcsp.com/cspbook.pdf
98

109
> In ancient times, a wealthy philanthropist endowed a College to accommodate
11-
> five eminent philosophers. Each philosopher had a room in which they could
12-
> engage in their professional activity of thinking; there was also a common
10+
> five eminent philosophers. Each philosopher had a room in which she could
11+
> engage in her professional activity of thinking; there was also a common
1312
> dining room, furnished with a circular table, surrounded by five chairs, each
1413
> labelled by the name of the philosopher who was to sit in it. They sat
1514
> anticlockwise around the table. To the left of each philosopher there was
1615
> laid a golden fork, and in the centre stood a large bowl of spaghetti, which
17-
> was constantly replenished. A philosopher was expected to spend most of
18-
> their time thinking; but when they felt hungry, they went to the dining
19-
> room, sat down in their own chair, picked up their own fork on their left,
20-
> and plunged it into the spaghetti. But such is the tangled nature of
21-
> spaghetti that a second fork is required to carry it to the mouth. The
22-
> philosopher therefore had also to pick up the fork on their right. When
23-
> they were finished they would put down both their forks, get up from their
24-
> chair, and continue thinking. Of course, a fork can be used by only one
25-
> philosopher at a time. If the other philosopher wants it, they just have
26-
> to wait until the fork is available again.
16+
> was constantly replenished. A philosopher was expected to spend most of her
17+
> time thinking; but when she felt hungry, she went to the dining room, sat down
18+
> in her own chair, picked up her own fork on her left, and plunged it into the
19+
> spaghetti. But such is the tangled nature of spaghetti that a second fork is
20+
> required to carry it to the mouth. The philosopher therefore had also to pick
21+
> up the fork on her right. When she was finished she would put down both her
22+
> forks, get up from her chair, and continue thinking. Of course, a fork can be
23+
> used by only one philosopher at a time. If the other philosopher wants it, she
24+
> just has to wait until the fork is available again.
2725
2826
This classic problem shows off a few different elements of concurrency. The
2927
reason is that it's actually slightly tricky to implement: a simple
@@ -62,10 +60,10 @@ impl Philosopher {
6260
}
6361

6462
fn main() {
65-
let p1 = Philosopher::new("Judith Butler");
63+
let p1 = Philosopher::new("Baruch Spinoza");
6664
let p2 = Philosopher::new("Gilles Deleuze");
6765
let p3 = Philosopher::new("Karl Marx");
68-
let p4 = Philosopher::new("Emma Goldman");
66+
let p4 = Philosopher::new("Friedrich Nietzsche");
6967
let p5 = Philosopher::new("Michel Foucault");
7068
}
7169
```
@@ -161,10 +159,10 @@ look at `main()` again:
161159
# }
162160
#
163161
fn main() {
164-
let p1 = Philosopher::new("Judith Butler");
162+
let p1 = Philosopher::new("Baruch Spinoza");
165163
let p2 = Philosopher::new("Gilles Deleuze");
166164
let p3 = Philosopher::new("Karl Marx");
167-
let p4 = Philosopher::new("Emma Goldman");
165+
let p4 = Philosopher::new("Friedrich Nietzsche");
168166
let p5 = Philosopher::new("Michel Foucault");
169167
}
170168
```
@@ -178,10 +176,10 @@ that `new()` function, it would look like this:
178176
# name: String,
179177
# }
180178
fn main() {
181-
let p1 = Philosopher { name: "Judith Butler".to_string() };
179+
let p1 = Philosopher { name: "Baruch Spinoza".to_string() };
182180
let p2 = Philosopher { name: "Gilles Deleuze".to_string() };
183181
let p3 = Philosopher { name: "Karl Marx".to_string() };
184-
let p4 = Philosopher { name: "Emma Goldman".to_string() };
182+
let p4 = Philosopher { name: "Friedrich Nietzche".to_string() };
185183
let p5 = Philosopher { name: "Michel Foucault".to_string() };
186184
}
187185
```
@@ -213,10 +211,10 @@ impl Philosopher {
213211

214212
fn main() {
215213
let philosophers = vec![
216-
Philosopher::new("Judith Butler"),
214+
Philosopher::new("Baruch Spinoza"),
217215
Philosopher::new("Gilles Deleuze"),
218216
Philosopher::new("Karl Marx"),
219-
Philosopher::new("Emma Goldman"),
217+
Philosopher::new("Friedrich Nietzsche"),
220218
Philosopher::new("Michel Foucault"),
221219
];
222220

@@ -249,10 +247,10 @@ mention they’re done eating. Running this program should give you the followin
249247
output:
250248

251249
```text
252-
Judith Butler is done eating.
250+
Baruch Spinoza is done eating.
253251
Gilles Deleuze is done eating.
254252
Karl Marx is done eating.
255-
Emma Goldman is done eating.
253+
Friedrich Nietzsche is done eating.
256254
Michel Foucault is done eating.
257255
```
258256

@@ -287,10 +285,10 @@ impl Philosopher {
287285

288286
fn main() {
289287
let philosophers = vec![
290-
Philosopher::new("Judith Butler"),
288+
Philosopher::new("Baruch Spinoza"),
291289
Philosopher::new("Gilles Deleuze"),
292290
Philosopher::new("Karl Marx"),
293-
Philosopher::new("Emma Goldman"),
291+
Philosopher::new("Friedrich Nietzsche"),
294292
Philosopher::new("Michel Foucault"),
295293
];
296294

@@ -325,14 +323,14 @@ simulate the time it takes a philosopher to eat.
325323
If you run this program, you should see each philosopher eat in turn:
326324

327325
```text
328-
Judith Butler is eating.
329-
Judith Butler is done eating.
326+
Baruch Spinoza is eating.
327+
Baruch Spinoza is done eating.
330328
Gilles Deleuze is eating.
331329
Gilles Deleuze is done eating.
332330
Karl Marx is eating.
333331
Karl Marx is done eating.
334-
Emma Goldman is eating.
335-
Emma Goldman is done eating.
332+
Friedrich Nietzsche is eating.
333+
Friedrich Nietzsche is done eating.
336334
Michel Foucault is eating.
337335
Michel Foucault is done eating.
338336
```
@@ -368,10 +366,10 @@ impl Philosopher {
368366

369367
fn main() {
370368
let philosophers = vec![
371-
Philosopher::new("Judith Butler"),
369+
Philosopher::new("Baruch Spinoza"),
372370
Philosopher::new("Gilles Deleuze"),
373371
Philosopher::new("Karl Marx"),
374-
Philosopher::new("Emma Goldman"),
372+
Philosopher::new("Friedrich Nietzsche"),
375373
Philosopher::new("Michel Foucault"),
376374
];
377375

@@ -460,11 +458,11 @@ We have multi-threading!
460458
```text
461459
Gilles Deleuze is eating.
462460
Gilles Deleuze is done eating.
463-
Emma Goldman is eating.
464-
Emma Goldman is done eating.
461+
Friedrich Nietzsche is eating.
462+
Friedrich Nietzsche is done eating.
465463
Michel Foucault is eating.
466-
Judith Butler is eating.
467-
Judith Butler is done eating.
464+
Baruch Spinoza is eating.
465+
Baruch Spinoza is done eating.
468466
Karl Marx is eating.
469467
Karl Marx is done eating.
470468
Michel Foucault is done eating.
@@ -534,10 +532,10 @@ fn main() {
534532
]});
535533

536534
let philosophers = vec![
537-
Philosopher::new("Judith Butler", 0, 1),
535+
Philosopher::new("Baruch Spinoza", 0, 1),
538536
Philosopher::new("Gilles Deleuze", 1, 2),
539537
Philosopher::new("Karl Marx", 2, 3),
540-
Philosopher::new("Emma Goldman", 3, 4),
538+
Philosopher::new("Friedrich Nietzsche", 3, 4),
541539
Philosopher::new("Michel Foucault", 0, 4),
542540
];
543541

@@ -645,10 +643,10 @@ count will go up, and when each thread ends, it will go back down.
645643

646644
```rust,ignore
647645
let philosophers = vec![
648-
Philosopher::new("Judith Butler", 0, 1),
646+
Philosopher::new("Baruch Spinoza", 0, 1),
649647
Philosopher::new("Gilles Deleuze", 1, 2),
650648
Philosopher::new("Karl Marx", 2, 3),
651-
Philosopher::new("Emma Goldman", 3, 4),
649+
Philosopher::new("Friedrich Nietzsche", 3, 4),
652650
Philosopher::new("Michel Foucault", 0, 4),
653651
];
654652
```
@@ -681,12 +679,12 @@ and so you’ll get some output like this:
681679

682680
```text
683681
Gilles Deleuze is eating.
684-
Emma Goldman is eating.
685-
Emma Goldman is done eating.
682+
Friedrich Nietzsche is eating.
683+
Friedrich Nietzsche is done eating.
686684
Gilles Deleuze is done eating.
687-
Judith Butler is eating.
685+
Baruch Spinoza is eating.
688686
Karl Marx is eating.
689-
Judith Butler is done eating.
687+
Baruch Spinoza is done eating.
690688
Michel Foucault is eating.
691689
Karl Marx is done eating.
692690
Michel Foucault is done eating.

branches/tmp/src/liballoc/rc.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@
144144
//! // At the end of the method, gadget_owner, gadget1 and gadget2 get
145145
//! // destroyed. There are now no strong (`Rc<T>`) references to the gadgets.
146146
//! // Once they get destroyed, the Gadgets get destroyed. This zeroes the
147-
//! // reference count on Gadget Man, they get destroyed as well.
147+
//! // reference count on Gadget Man, so he gets destroyed as well.
148148
//! }
149149
//! ```
150150

branches/tmp/src/libcollections/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
#![feature(str_char)]
4040
#![feature(str_words)]
4141
#![feature(slice_patterns)]
42+
#![feature(debug_builders)]
4243
#![feature(utf8_error)]
4344
#![cfg_attr(test, feature(rand, rustc_private, test, hash, collections,
4445
collections_drain, collections_range))]

branches/tmp/src/libcore/fmt/builders.rs

Lines changed: 13 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@ impl<'a, 'b: 'a> fmt::Write for PadAdapter<'a, 'b> {
5454
///
5555
/// Constructed by the `Formatter::debug_struct` method.
5656
#[must_use]
57-
#[stable(feature = "debug_builders", since = "1.2.0")]
5857
pub struct DebugStruct<'a, 'b: 'a> {
5958
fmt: &'a mut fmt::Formatter<'b>,
6059
result: fmt::Result,
@@ -73,7 +72,7 @@ pub fn debug_struct_new<'a, 'b>(fmt: &'a mut fmt::Formatter<'b>, name: &str)
7372

7473
impl<'a, 'b: 'a> DebugStruct<'a, 'b> {
7574
/// Adds a new field to the generated struct output.
76-
#[stable(feature = "debug_builders", since = "1.2.0")]
75+
#[unstable(feature = "debug_builders", reason = "method was just created")]
7776
pub fn field(&mut self, name: &str, value: &fmt::Debug) -> &mut DebugStruct<'a, 'b> {
7877
self.result = self.result.and_then(|_| {
7978
let prefix = if self.has_fields {
@@ -95,7 +94,7 @@ impl<'a, 'b: 'a> DebugStruct<'a, 'b> {
9594
}
9695

9796
/// Finishes output and returns any error encountered.
98-
#[stable(feature = "debug_builders", since = "1.2.0")]
97+
#[unstable(feature = "debug_builders", reason = "method was just created")]
9998
pub fn finish(&mut self) -> fmt::Result {
10099
if self.has_fields {
101100
self.result = self.result.and_then(|_| {
@@ -118,7 +117,6 @@ impl<'a, 'b: 'a> DebugStruct<'a, 'b> {
118117
///
119118
/// Constructed by the `Formatter::debug_tuple` method.
120119
#[must_use]
121-
#[stable(feature = "debug_builders", since = "1.2.0")]
122120
pub struct DebugTuple<'a, 'b: 'a> {
123121
fmt: &'a mut fmt::Formatter<'b>,
124122
result: fmt::Result,
@@ -136,7 +134,7 @@ pub fn debug_tuple_new<'a, 'b>(fmt: &'a mut fmt::Formatter<'b>, name: &str) -> D
136134

137135
impl<'a, 'b: 'a> DebugTuple<'a, 'b> {
138136
/// Adds a new field to the generated tuple struct output.
139-
#[stable(feature = "debug_builders", since = "1.2.0")]
137+
#[unstable(feature = "debug_builders", reason = "method was just created")]
140138
pub fn field(&mut self, value: &fmt::Debug) -> &mut DebugTuple<'a, 'b> {
141139
self.result = self.result.and_then(|_| {
142140
let (prefix, space) = if self.has_fields {
@@ -158,7 +156,7 @@ impl<'a, 'b: 'a> DebugTuple<'a, 'b> {
158156
}
159157

160158
/// Finishes output and returns any error encountered.
161-
#[stable(feature = "debug_builders", since = "1.2.0")]
159+
#[unstable(feature = "debug_builders", reason = "method was just created")]
162160
pub fn finish(&mut self) -> fmt::Result {
163161
if self.has_fields {
164162
self.result = self.result.and_then(|_| {
@@ -213,7 +211,6 @@ impl<'a, 'b: 'a> DebugInner<'a, 'b> {
213211
///
214212
/// Constructed by the `Formatter::debug_set` method.
215213
#[must_use]
216-
#[stable(feature = "debug_builders", since = "1.2.0")]
217214
pub struct DebugSet<'a, 'b: 'a> {
218215
inner: DebugInner<'a, 'b>,
219216
}
@@ -231,14 +228,14 @@ pub fn debug_set_new<'a, 'b>(fmt: &'a mut fmt::Formatter<'b>) -> DebugSet<'a, 'b
231228

232229
impl<'a, 'b: 'a> DebugSet<'a, 'b> {
233230
/// Adds a new entry to the set output.
234-
#[stable(feature = "debug_builders", since = "1.2.0")]
231+
#[unstable(feature = "debug_builders", reason = "method was just created")]
235232
pub fn entry(&mut self, entry: &fmt::Debug) -> &mut DebugSet<'a, 'b> {
236233
self.inner.entry(entry);
237234
self
238235
}
239236

240237
/// Adds the contents of an iterator of entries to the set output.
241-
#[stable(feature = "debug_builders", since = "1.2.0")]
238+
#[unstable(feature = "debug_builders", reason = "method was just created")]
242239
pub fn entries<D, I>(&mut self, entries: I) -> &mut DebugSet<'a, 'b>
243240
where D: fmt::Debug, I: IntoIterator<Item=D> {
244241
for entry in entries {
@@ -248,7 +245,7 @@ impl<'a, 'b: 'a> DebugSet<'a, 'b> {
248245
}
249246

250247
/// Finishes output and returns any error encountered.
251-
#[stable(feature = "debug_builders", since = "1.2.0")]
248+
#[unstable(feature = "debug_builders", reason = "method was just created")]
252249
pub fn finish(&mut self) -> fmt::Result {
253250
self.inner.finish();
254251
self.inner.result.and_then(|_| self.inner.fmt.write_str("}"))
@@ -259,7 +256,6 @@ impl<'a, 'b: 'a> DebugSet<'a, 'b> {
259256
///
260257
/// Constructed by the `Formatter::debug_list` method.
261258
#[must_use]
262-
#[stable(feature = "debug_builders", since = "1.2.0")]
263259
pub struct DebugList<'a, 'b: 'a> {
264260
inner: DebugInner<'a, 'b>,
265261
}
@@ -277,14 +273,14 @@ pub fn debug_list_new<'a, 'b>(fmt: &'a mut fmt::Formatter<'b>) -> DebugList<'a,
277273

278274
impl<'a, 'b: 'a> DebugList<'a, 'b> {
279275
/// Adds a new entry to the list output.
280-
#[stable(feature = "debug_builders", since = "1.2.0")]
276+
#[unstable(feature = "debug_builders", reason = "method was just created")]
281277
pub fn entry(&mut self, entry: &fmt::Debug) -> &mut DebugList<'a, 'b> {
282278
self.inner.entry(entry);
283279
self
284280
}
285281

286282
/// Adds the contents of an iterator of entries to the list output.
287-
#[stable(feature = "debug_builders", since = "1.2.0")]
283+
#[unstable(feature = "debug_builders", reason = "method was just created")]
288284
pub fn entries<D, I>(&mut self, entries: I) -> &mut DebugList<'a, 'b>
289285
where D: fmt::Debug, I: IntoIterator<Item=D> {
290286
for entry in entries {
@@ -294,7 +290,7 @@ impl<'a, 'b: 'a> DebugList<'a, 'b> {
294290
}
295291

296292
/// Finishes output and returns any error encountered.
297-
#[stable(feature = "debug_builders", since = "1.2.0")]
293+
#[unstable(feature = "debug_builders", reason = "method was just created")]
298294
pub fn finish(&mut self) -> fmt::Result {
299295
self.inner.finish();
300296
self.inner.result.and_then(|_| self.inner.fmt.write_str("]"))
@@ -305,7 +301,6 @@ impl<'a, 'b: 'a> DebugList<'a, 'b> {
305301
///
306302
/// Constructed by the `Formatter::debug_map` method.
307303
#[must_use]
308-
#[stable(feature = "debug_builders", since = "1.2.0")]
309304
pub struct DebugMap<'a, 'b: 'a> {
310305
fmt: &'a mut fmt::Formatter<'b>,
311306
result: fmt::Result,
@@ -323,7 +318,7 @@ pub fn debug_map_new<'a, 'b>(fmt: &'a mut fmt::Formatter<'b>) -> DebugMap<'a, 'b
323318

324319
impl<'a, 'b: 'a> DebugMap<'a, 'b> {
325320
/// Adds a new entry to the map output.
326-
#[stable(feature = "debug_builders", since = "1.2.0")]
321+
#[unstable(feature = "debug_builders", reason = "method was just created")]
327322
pub fn entry(&mut self, key: &fmt::Debug, value: &fmt::Debug) -> &mut DebugMap<'a, 'b> {
328323
self.result = self.result.and_then(|_| {
329324
if self.is_pretty() {
@@ -341,7 +336,7 @@ impl<'a, 'b: 'a> DebugMap<'a, 'b> {
341336
}
342337

343338
/// Adds the contents of an iterator of entries to the map output.
344-
#[stable(feature = "debug_builders", since = "1.2.0")]
339+
#[unstable(feature = "debug_builders", reason = "method was just created")]
345340
pub fn entries<K, V, I>(&mut self, entries: I) -> &mut DebugMap<'a, 'b>
346341
where K: fmt::Debug, V: fmt::Debug, I: IntoIterator<Item=(K, V)> {
347342
for (k, v) in entries {
@@ -351,7 +346,7 @@ impl<'a, 'b: 'a> DebugMap<'a, 'b> {
351346
}
352347

353348
/// Finishes output and returns any error encountered.
354-
#[stable(feature = "debug_builders", since = "1.2.0")]
349+
#[unstable(feature = "debug_builders", reason = "method was just created")]
355350
pub fn finish(&mut self) -> fmt::Result {
356351
let prefix = if self.is_pretty() && self.has_fields { "\n" } else { "" };
357352
self.result.and_then(|_| write!(self.fmt, "{}}}", prefix))

0 commit comments

Comments
 (0)