rust/src/libstd
bors 20dc0c5070 Auto merge of #54174 - parched:park, r=alexcrichton
Fix `thread` `park`/`unpark` synchronization

Previously the code below would not be guaranteed to exit when the
second unpark took the `return, // already unparked` path because there
was no write to synchronize with a read in `park`.

EDIT: doesn't actually require third thread
```
use std::sync::atomic::{AtomicBool, Ordering};
use std:🧵:{current, spawn, park};

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

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

    while !FLAG.load(Ordering::Relaxed) {
        park();
    }
}
```

I have some other ideas on how to improve the performance of `park` and `unpark` using fences, avoiding any atomic RMW when the state is already `NOTIFIED`, and also how to avoid calling `notify_one` without the mutex locked. But I need to write some micro benchmarks first, so I'll submit those changes at a later date if they prove to be faster.

Fixes https://github.com/rust-lang/rust/issues/53366 I hope.
2018-09-19 17:08:28 +00:00
..
collections Auto merge of #53804 - RalfJung:ptr-invalid, r=nagisa 2018-09-16 18:03:39 +00:00
ffi OsStr: Document that it's not NUL terminated 2018-09-17 21:10:36 -04:00
io Rollup merge of #54046 - snaedis:issue-48022, r=steveklabnik 2018-09-12 12:17:28 +08:00
net Rollup merge of #53522 - phungleson:fix-impl-from-for-addr, r=TimNN 2018-09-18 10:21:33 +02:00
os Move std::os::raw::c_void into libcore and re-export in libstd 2018-09-14 16:19:59 +01:00
prelude Reformat std prelude source to show it is the sum of core and alloc preludes 2018-07-07 23:16:27 +02:00
sync Fix invalid urls 2018-09-06 23:32:30 +02:00
sys Auto merge of #53621 - jordanrh1:windows-arm, r=alexcrichton 2018-09-13 15:22:05 +00:00
sys_common Improve output if no_lookup_host_duplicates fails 2018-09-15 17:17:35 +02:00
tests Breaking change upgrades 2018-09-04 13:22:08 -06:00
thread Expand synchronization comments in park/unpark 2018-09-18 18:06:16 +01:00
alloc.rs rustc: Continue to tweak "std internal symbols" 2018-08-26 16:34:14 -07:00
ascii.rs Remove unstable and deprecated APIs 2018-07-30 18:18:23 +02:00
build.rs Add rustc SHA to released DWARF debuginfo 2018-09-10 10:10:38 -07:00
Cargo.toml Breaking change upgrades 2018-09-04 13:22:08 -06:00
env.rs make reference to dirs crate clickable in terminals 2018-07-12 12:48:10 +02:00
error.rs Correctly parenthesize dyn Error + 'static. 2018-08-21 00:58:52 +02:00
f32.rs Clarify rational behind current implementation of .mod_euc() 2018-06-26 13:09:56 +02:00
f64.rs Clarify rational behind current implementation of .mod_euc() 2018-06-26 13:09:56 +02:00
fs.rs Rollup merge of #53376 - frewsxcv:frewsxcv-copy, r=GuillaumeGomez 2018-09-07 15:26:30 +08:00
future.rs Update to a new pinning API. 2018-09-01 06:57:58 +02:00
keyword_docs.rs Add struct keyword doc 2018-08-23 23:50:05 +02:00
lib.rs Auto merge of #53877 - withoutboats:compositional-pin, r=aturon 2018-09-19 06:56:19 +00:00
macros.rs Auto merge of #53877 - withoutboats:compositional-pin, r=aturon 2018-09-19 06:56:19 +00:00
memchr.rs Fix typos found by codespell. 2018-08-19 17:41:28 +02:00
num.rs Stabilize num::NonZeroU* 2018-05-16 19:11:31 +02:00
panic.rs Update to a new pinning API. 2018-09-01 06:57:58 +02:00
panicking.rs add #[panic_handler]; deprecate #[panic_implementation] 2018-08-23 20:58:55 +02:00
path.rs Add links to std::char::REPLACEMENT_CHARACTER from docs. 2018-08-11 15:42:35 -04:00
primitive_docs.rs re-mark the never docs as unstable 2018-09-13 17:31:56 -05:00
process.rs document the platform-specific behavior of Command::current_dir 2018-08-20 17:02:45 -04:00
rt.rs Deny bare trait objects in src/libstd. 2018-07-10 20:35:36 +02:00
time.rs Stabilize SystemTime::UNIX_EPOCH 2018-05-28 18:24:01 -06:00