Skip to content

Commit dc894b1

Browse files
authored
Update arc.md (#255)
Adding more information about `Arc`: what it stands for, costs and that reference cycles can occur.
1 parent 8107a0e commit dc894b1

File tree

1 file changed

+9
-0
lines changed
  • src/concurrency/shared_state

1 file changed

+9
-0
lines changed

src/concurrency/shared_state/arc.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,12 @@ fn main() {
2323
```
2424

2525
[1]: https://doc.rust-lang.org/std/sync/struct.Arc.html
26+
27+
<details>
28+
29+
* `Arc` stands for "Atomic Reference Counted", a thread safe version of `Rc` that uses atomic operations.
30+
* `Arc::clone()` has the cost of atomic operations that get executed, but after that the use of the `T` is free.
31+
* Beware of reference cycles, Rust does not have a garbage collector to detect those.
32+
* `std::sync::Weak` can help.
33+
34+
</details>

0 commit comments

Comments
 (0)