about summary refs log tree commit diff
path: root/src/test/incremental/thinlto
diff options
context:
space:
mode:
authorJames Duley <james.duley@arm.com>2018-09-11 18:04:33 +0100
committerJames Duley <james.duley@arm.com>2018-09-12 18:55:44 +0100
commit204d9608e35f7dc56e179d4539e931766fd88f28 (patch)
treeec8b05190dd4caa304adbb892b19d623fceeacdc /src/test/incremental/thinlto
parent7ee72070bdb789f58f272fab50d49bd48dd9c11f (diff)
downloadrust-204d9608e35f7dc56e179d4539e931766fd88f28.tar.gz
rust-204d9608e35f7dc56e179d4539e931766fd88f28.zip
Fix `thread` `park`/`unpark` synchronization
Previously the code below would not be guaranteed to exit when the first
spawned thread took the `return, // already unparked` path because there
was no write to synchronize with a read in `park`.

```
use std::sync::atomic::{AtomicBool, Ordering};
use std::thread::{current, spawn, park};

static FLAG: AtomicBool = AtomicBool::new(false);

fn main() {
    let thread_0 = current();
    spawn(move || {
        FLAG.store(true, Ordering::Relaxed);
        thread_0.unpark();
    });

    let thread_0 = current();
    spawn(move || {
        thread_0.unpark();
    });

    while !FLAG.load(Ordering::Relaxed) {
        park();
    }
}
```
Diffstat (limited to 'src/test/incremental/thinlto')
0 files changed, 0 insertions, 0 deletions