Skip to content

Commit a68a961

Browse files
committed
---
yaml --- r: 207706 b: refs/heads/tmp c: 41f2c81 h: refs/heads/master v: v3
1 parent 2b74362 commit a68a961

File tree

15 files changed

+280
-224
lines changed

15 files changed

+280
-224
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: 5dc03a8246e76e9e3900d98f2f5d2574abaeaa6b
35+
refs/heads/tmp: 41f2c81103a5756ca438723232b1adad7bc4ccf3
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: 44 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -2,26 +2,28 @@
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 the version from [this paper][paper] by Tony Hoare in 1985.
5+
1965, but we’ll use a lightly adapted version from [this paper][paper] by Tony
6+
Hoare in 1985.
67

78
[paper]: http://www.usingcsp.com/cspbook.pdf
89

910
> In ancient times, a wealthy philanthropist endowed a College to accommodate
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
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
1213
> dining room, furnished with a circular table, surrounded by five chairs, each
1314
> labelled by the name of the philosopher who was to sit in it. They sat
1415
> anticlockwise around the table. To the left of each philosopher there was
1516
> laid a golden fork, and in the centre stood a large bowl of spaghetti, which
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.
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.
2527
2628
This classic problem shows off a few different elements of concurrency. The
2729
reason is that it's actually slightly tricky to implement: a simple
@@ -60,10 +62,10 @@ impl Philosopher {
6062
}
6163

6264
fn main() {
63-
let p1 = Philosopher::new("Baruch Spinoza");
65+
let p1 = Philosopher::new("Judith Butler");
6466
let p2 = Philosopher::new("Gilles Deleuze");
6567
let p3 = Philosopher::new("Karl Marx");
66-
let p4 = Philosopher::new("Friedrich Nietzsche");
68+
let p4 = Philosopher::new("Emma Goldman");
6769
let p5 = Philosopher::new("Michel Foucault");
6870
}
6971
```
@@ -159,10 +161,10 @@ look at `main()` again:
159161
# }
160162
#
161163
fn main() {
162-
let p1 = Philosopher::new("Baruch Spinoza");
164+
let p1 = Philosopher::new("Judith Butler");
163165
let p2 = Philosopher::new("Gilles Deleuze");
164166
let p3 = Philosopher::new("Karl Marx");
165-
let p4 = Philosopher::new("Friedrich Nietzsche");
167+
let p4 = Philosopher::new("Emma Goldman");
166168
let p5 = Philosopher::new("Michel Foucault");
167169
}
168170
```
@@ -176,10 +178,10 @@ that `new()` function, it would look like this:
176178
# name: String,
177179
# }
178180
fn main() {
179-
let p1 = Philosopher { name: "Baruch Spinoza".to_string() };
181+
let p1 = Philosopher { name: "Judith Butler".to_string() };
180182
let p2 = Philosopher { name: "Gilles Deleuze".to_string() };
181183
let p3 = Philosopher { name: "Karl Marx".to_string() };
182-
let p4 = Philosopher { name: "Friedrich Nietzche".to_string() };
184+
let p4 = Philosopher { name: "Emma Goldman".to_string() };
183185
let p5 = Philosopher { name: "Michel Foucault".to_string() };
184186
}
185187
```
@@ -211,10 +213,10 @@ impl Philosopher {
211213

212214
fn main() {
213215
let philosophers = vec![
214-
Philosopher::new("Baruch Spinoza"),
216+
Philosopher::new("Judith Butler"),
215217
Philosopher::new("Gilles Deleuze"),
216218
Philosopher::new("Karl Marx"),
217-
Philosopher::new("Friedrich Nietzsche"),
219+
Philosopher::new("Emma Goldman"),
218220
Philosopher::new("Michel Foucault"),
219221
];
220222

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

249251
```text
250-
Baruch Spinoza is done eating.
252+
Judith Butler is done eating.
251253
Gilles Deleuze is done eating.
252254
Karl Marx is done eating.
253-
Friedrich Nietzsche is done eating.
255+
Emma Goldman is done eating.
254256
Michel Foucault is done eating.
255257
```
256258

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

286288
fn main() {
287289
let philosophers = vec![
288-
Philosopher::new("Baruch Spinoza"),
290+
Philosopher::new("Judith Butler"),
289291
Philosopher::new("Gilles Deleuze"),
290292
Philosopher::new("Karl Marx"),
291-
Philosopher::new("Friedrich Nietzsche"),
293+
Philosopher::new("Emma Goldman"),
292294
Philosopher::new("Michel Foucault"),
293295
];
294296

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

325327
```text
326-
Baruch Spinoza is eating.
327-
Baruch Spinoza is done eating.
328+
Judith Butler is eating.
329+
Judith Butler is done eating.
328330
Gilles Deleuze is eating.
329331
Gilles Deleuze is done eating.
330332
Karl Marx is eating.
331333
Karl Marx is done eating.
332-
Friedrich Nietzsche is eating.
333-
Friedrich Nietzsche is done eating.
334+
Emma Goldman is eating.
335+
Emma Goldman is done eating.
334336
Michel Foucault is eating.
335337
Michel Foucault is done eating.
336338
```
@@ -366,10 +368,10 @@ impl Philosopher {
366368

367369
fn main() {
368370
let philosophers = vec![
369-
Philosopher::new("Baruch Spinoza"),
371+
Philosopher::new("Judith Butler"),
370372
Philosopher::new("Gilles Deleuze"),
371373
Philosopher::new("Karl Marx"),
372-
Philosopher::new("Friedrich Nietzsche"),
374+
Philosopher::new("Emma Goldman"),
373375
Philosopher::new("Michel Foucault"),
374376
];
375377

@@ -458,11 +460,11 @@ We have multi-threading!
458460
```text
459461
Gilles Deleuze is eating.
460462
Gilles Deleuze is done eating.
461-
Friedrich Nietzsche is eating.
462-
Friedrich Nietzsche is done eating.
463+
Emma Goldman is eating.
464+
Emma Goldman is done eating.
463465
Michel Foucault is eating.
464-
Baruch Spinoza is eating.
465-
Baruch Spinoza is done eating.
466+
Judith Butler is eating.
467+
Judith Butler is done eating.
466468
Karl Marx is eating.
467469
Karl Marx is done eating.
468470
Michel Foucault is done eating.
@@ -532,10 +534,10 @@ fn main() {
532534
]});
533535

534536
let philosophers = vec![
535-
Philosopher::new("Baruch Spinoza", 0, 1),
537+
Philosopher::new("Judith Butler", 0, 1),
536538
Philosopher::new("Gilles Deleuze", 1, 2),
537539
Philosopher::new("Karl Marx", 2, 3),
538-
Philosopher::new("Friedrich Nietzsche", 3, 4),
540+
Philosopher::new("Emma Goldman", 3, 4),
539541
Philosopher::new("Michel Foucault", 0, 4),
540542
];
541543

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

644646
```rust,ignore
645647
let philosophers = vec![
646-
Philosopher::new("Baruch Spinoza", 0, 1),
648+
Philosopher::new("Judith Butler", 0, 1),
647649
Philosopher::new("Gilles Deleuze", 1, 2),
648650
Philosopher::new("Karl Marx", 2, 3),
649-
Philosopher::new("Friedrich Nietzsche", 3, 4),
651+
Philosopher::new("Emma Goldman", 3, 4),
650652
Philosopher::new("Michel Foucault", 0, 4),
651653
];
652654
```
@@ -679,12 +681,12 @@ and so you’ll get some output like this:
679681

680682
```text
681683
Gilles Deleuze is eating.
682-
Friedrich Nietzsche is eating.
683-
Friedrich Nietzsche is done eating.
684+
Emma Goldman is eating.
685+
Emma Goldman is done eating.
684686
Gilles Deleuze is done eating.
685-
Baruch Spinoza is eating.
687+
Judith Butler is eating.
686688
Karl Marx is eating.
687-
Baruch Spinoza is done eating.
689+
Judith Butler is done eating.
688690
Michel Foucault is eating.
689691
Karl Marx is done eating.
690692
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, so he gets destroyed as well.
147+
//! // reference count on Gadget Man, they get destroyed as well.
148148
//! }
149149
//! ```
150150

branches/tmp/src/libcollections/lib.rs

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

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

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ 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")]
5758
pub struct DebugStruct<'a, 'b: 'a> {
5859
fmt: &'a mut fmt::Formatter<'b>,
5960
result: fmt::Result,
@@ -72,7 +73,7 @@ pub fn debug_struct_new<'a, 'b>(fmt: &'a mut fmt::Formatter<'b>, name: &str)
7273

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

9697
/// Finishes output and returns any error encountered.
97-
#[unstable(feature = "debug_builders", reason = "method was just created")]
98+
#[stable(feature = "debug_builders", since = "1.2.0")]
9899
pub fn finish(&mut self) -> fmt::Result {
99100
if self.has_fields {
100101
self.result = self.result.and_then(|_| {
@@ -117,6 +118,7 @@ impl<'a, 'b: 'a> DebugStruct<'a, 'b> {
117118
///
118119
/// Constructed by the `Formatter::debug_tuple` method.
119120
#[must_use]
121+
#[stable(feature = "debug_builders", since = "1.2.0")]
120122
pub struct DebugTuple<'a, 'b: 'a> {
121123
fmt: &'a mut fmt::Formatter<'b>,
122124
result: fmt::Result,
@@ -134,7 +136,7 @@ pub fn debug_tuple_new<'a, 'b>(fmt: &'a mut fmt::Formatter<'b>, name: &str) -> D
134136

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

158160
/// Finishes output and returns any error encountered.
159-
#[unstable(feature = "debug_builders", reason = "method was just created")]
161+
#[stable(feature = "debug_builders", since = "1.2.0")]
160162
pub fn finish(&mut self) -> fmt::Result {
161163
if self.has_fields {
162164
self.result = self.result.and_then(|_| {
@@ -211,6 +213,7 @@ impl<'a, 'b: 'a> DebugInner<'a, 'b> {
211213
///
212214
/// Constructed by the `Formatter::debug_set` method.
213215
#[must_use]
216+
#[stable(feature = "debug_builders", since = "1.2.0")]
214217
pub struct DebugSet<'a, 'b: 'a> {
215218
inner: DebugInner<'a, 'b>,
216219
}
@@ -228,14 +231,14 @@ pub fn debug_set_new<'a, 'b>(fmt: &'a mut fmt::Formatter<'b>) -> DebugSet<'a, 'b
228231

229232
impl<'a, 'b: 'a> DebugSet<'a, 'b> {
230233
/// Adds a new entry to the set output.
231-
#[unstable(feature = "debug_builders", reason = "method was just created")]
234+
#[stable(feature = "debug_builders", since = "1.2.0")]
232235
pub fn entry(&mut self, entry: &fmt::Debug) -> &mut DebugSet<'a, 'b> {
233236
self.inner.entry(entry);
234237
self
235238
}
236239

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

247250
/// Finishes output and returns any error encountered.
248-
#[unstable(feature = "debug_builders", reason = "method was just created")]
251+
#[stable(feature = "debug_builders", since = "1.2.0")]
249252
pub fn finish(&mut self) -> fmt::Result {
250253
self.inner.finish();
251254
self.inner.result.and_then(|_| self.inner.fmt.write_str("}"))
@@ -256,6 +259,7 @@ impl<'a, 'b: 'a> DebugSet<'a, 'b> {
256259
///
257260
/// Constructed by the `Formatter::debug_list` method.
258261
#[must_use]
262+
#[stable(feature = "debug_builders", since = "1.2.0")]
259263
pub struct DebugList<'a, 'b: 'a> {
260264
inner: DebugInner<'a, 'b>,
261265
}
@@ -273,14 +277,14 @@ pub fn debug_list_new<'a, 'b>(fmt: &'a mut fmt::Formatter<'b>) -> DebugList<'a,
273277

274278
impl<'a, 'b: 'a> DebugList<'a, 'b> {
275279
/// Adds a new entry to the list output.
276-
#[unstable(feature = "debug_builders", reason = "method was just created")]
280+
#[stable(feature = "debug_builders", since = "1.2.0")]
277281
pub fn entry(&mut self, entry: &fmt::Debug) -> &mut DebugList<'a, 'b> {
278282
self.inner.entry(entry);
279283
self
280284
}
281285

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

292296
/// Finishes output and returns any error encountered.
293-
#[unstable(feature = "debug_builders", reason = "method was just created")]
297+
#[stable(feature = "debug_builders", since = "1.2.0")]
294298
pub fn finish(&mut self) -> fmt::Result {
295299
self.inner.finish();
296300
self.inner.result.and_then(|_| self.inner.fmt.write_str("]"))
@@ -301,6 +305,7 @@ impl<'a, 'b: 'a> DebugList<'a, 'b> {
301305
///
302306
/// Constructed by the `Formatter::debug_map` method.
303307
#[must_use]
308+
#[stable(feature = "debug_builders", since = "1.2.0")]
304309
pub struct DebugMap<'a, 'b: 'a> {
305310
fmt: &'a mut fmt::Formatter<'b>,
306311
result: fmt::Result,
@@ -318,7 +323,7 @@ pub fn debug_map_new<'a, 'b>(fmt: &'a mut fmt::Formatter<'b>) -> DebugMap<'a, 'b
318323

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

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

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

0 commit comments

Comments
 (0)