summaryrefslogtreecommitdiffstats
path: root/src/tools/clippy/src/docs/mutex_atomic.txt
blob: 062ac8b323b742fa430cfc3ce1c6f35a35acc292 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
### What it does
Checks for usages of `Mutex<X>` where an atomic will do.

### Why is this bad?
Using a mutex just to make access to a plain bool or
reference sequential is shooting flies with cannons.
`std::sync::atomic::AtomicBool` and `std::sync::atomic::AtomicPtr` are leaner and
faster.

### Known problems
This lint cannot detect if the mutex is actually used
for waiting before a critical section.

### Example
```
let x = Mutex::new(&y);
```

Use instead:
```
let x = AtomicBool::new(y);
```