File tree Expand file tree Collapse file tree 1 file changed +4
-4
lines changed Expand file tree Collapse file tree 1 file changed +4
-4
lines changed Original file line number Diff line number Diff line change @@ -210,18 +210,18 @@ use std::sync::atomic::{AtomicBool, Ordering};
210
210
use std :: thread;
211
211
212
212
fn main () {
213
- let lock = Arc :: new (AtomicBool :: new (true )); // value answers "am I locked?"
213
+ let lock = Arc :: new (AtomicBool :: new (false )); // value answers "am I locked?"
214
214
215
215
// ... distribute lock to threads somehow ...
216
216
217
- // Try to acquire the lock by setting it to false
218
- while ! lock . compare_and_swap (true , false , Ordering :: Acquire ) { }
217
+ // Try to acquire the lock by setting it to true
218
+ while lock . compare_and_swap (false , true , Ordering :: Acquire ) { }
219
219
// broke out of the loop, so we successfully acquired the lock!
220
220
221
221
// ... scary data accesses ...
222
222
223
223
// ok we're done, release the lock
224
- lock . store (true , Ordering :: Release );
224
+ lock . store (false , Ordering :: Release );
225
225
}
226
226
```
227
227
You can’t perform that action at this time.
0 commit comments