Skip to content

Commit dec6772

Browse files
committed
Improve the comment of arc1
1 parent b4f4c79 commit dec6772

File tree

2 files changed

+12
-6
lines changed

2 files changed

+12
-6
lines changed

exercises/19_smart_pointers/arc1.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// In this exercise, we are given a `Vec` of u32 called `numbers` with values
1+
// In this exercise, we are given a `Vec` of `u32` called `numbers` with values
22
// ranging from 0 to 99. We would like to use this set of numbers within 8
33
// different threads simultaneously. Each thread is going to get the sum of
44
// every eighth value with an offset.
@@ -9,8 +9,11 @@
99
// …
1010
// The eighth thread (offset 7), will sum 7, 15, 23, …
1111
//
12-
// Because we are using threads, our values need to be thread-safe. Therefore,
13-
// we are using `Arc`.
12+
// Each thread should own a reference-counting pointer to the vector of
13+
// numbers. But `Rc` isn't thread-safe. Therefore, we need to use `Arc`.
14+
//
15+
// Don't get distracted by how threads are spawned and joined. We will practice
16+
// that later in the exercises about threads.
1417

1518
// Don't change the lines below.
1619
#![forbid(unused_imports)]

solutions/19_smart_pointers/arc1.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// In this exercise, we are given a `Vec` of u32 called `numbers` with values
1+
// In this exercise, we are given a `Vec` of `u32` called `numbers` with values
22
// ranging from 0 to 99. We would like to use this set of numbers within 8
33
// different threads simultaneously. Each thread is going to get the sum of
44
// every eighth value with an offset.
@@ -9,8 +9,11 @@
99
// …
1010
// The eighth thread (offset 7), will sum 7, 15, 23, …
1111
//
12-
// Because we are using threads, our values need to be thread-safe. Therefore,
13-
// we are using `Arc`.
12+
// Each thread should own a reference-counting pointer to the vector of
13+
// numbers. But `Rc` isn't thread-safe. Therefore, we need to use `Arc`.
14+
//
15+
// Don't get distracted by how threads are spawned and joined. We will practice
16+
// that later in the exercises about threads.
1417

1518
// Don't change the lines below.
1619
#![forbid(unused_imports)]

0 commit comments

Comments
 (0)