File tree Expand file tree Collapse file tree 1 file changed +25
-1
lines changed Expand file tree Collapse file tree 1 file changed +25
-1
lines changed Original file line number Diff line number Diff line change 8
8
// option. This file may not be copied, modified, or distributed
9
9
// except according to those terms.
10
10
11
- /**
11
+ /*!
12
12
* Concurrency-enabled mechanisms for sharing mutable and/or immutable state
13
13
* between tasks.
14
+ *
15
+ * # Example
16
+ *
17
+ * In this example, a large vector of floats is shared between several tasks.
18
+ * With simple pipes, without ARC, a copy would have to be made for each task.
19
+ *
20
+ * ~~~
21
+ * # extern mod std;
22
+ * # use std::arc;
23
+ * let numbers=vec::from_fn(100, |ind| (ind as float)*rand::random());
24
+ * let shared_numbers=arc::ARC(numbers);
25
+ *
26
+ * for 10.times {
27
+ * let (port, chan) = stream();
28
+ * chan.send(shared_numbers.clone());
29
+ *
30
+ * do spawn {
31
+ * let shared_numbers=port.recv();
32
+ * let local_numbers=shared_numbers.get();
33
+ *
34
+ * // Work with the local numbers
35
+ * }
36
+ * }
37
+ * ~~~
14
38
*/
15
39
16
40
use sync;
You can’t perform that action at this time.
0 commit comments