Skip to content

Commit

Permalink
join_orders_after_tls_destructors: ensure thread 2 is launched before…
Browse files Browse the repository at this point in the history
… thread 1 enters TLS destructors
  • Loading branch information
mzohreva committed May 6, 2021
1 parent 8a0a4b1 commit 2acd62d
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions library/std/src/thread/local/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -250,13 +250,6 @@ fn join_orders_after_tls_destructors() {

impl Drop for TlDrop {
fn drop(&mut self) {
loop {
match SYNC_STATE.load(Ordering::SeqCst) {
FRESH => thread::yield_now(),
THREAD2_LAUNCHED => break,
v => unreachable!("sync state: {}", v),
}
}
let mut sync_state = SYNC_STATE.swap(THREAD1_WAITING, Ordering::SeqCst);
loop {
match sync_state {
Expand All @@ -276,7 +269,15 @@ fn join_orders_after_tls_destructors() {
static TL_DROP: TlDrop = TlDrop;
}

TL_DROP.with(|_| {})
TL_DROP.with(|_| {});

loop {
match SYNC_STATE.load(Ordering::SeqCst) {
FRESH => thread::yield_now(),
THREAD2_LAUNCHED => break,
v => unreachable!("sync state: {}", v),
}
}
})
.unwrap();

Expand Down

0 comments on commit 2acd62d

Please sign in to comment.