Skip to content

Conversation

RalfJung
Copy link
Member

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-libs Relevant to the library team, which will review and decide on the PR/issue. labels Aug 26, 2025
@rustbot
Copy link
Collaborator

rustbot commented Aug 26, 2025

The Miri subtree was changed

cc @rust-lang/miri

/// use std::time::Duration;
///
/// let flag = Arc::new(AtomicBool::new(false));
/// let flag2 = Arc::clone(&flag);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I switches this from Arc to static as I find that easier to read.

/// while !flag2.load(Ordering::Relaxed) {
/// println!("Parking thread");
/// while !FLAG.load(Ordering::Acquire) {
/// // `eprintln!` does not do any thread parking internally so we can safely call it here.
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we actually guarantee that eprintln! does not park, so this comment is dubious.

/// // We want to wait until the flag is set. We *could* just spin, but using
/// // park/unpark is more efficient.
/// while !flag2.load(Ordering::Relaxed) {
/// println!("Parking thread");
/// while !FLAG.load(Ordering::Acquire) {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I used release/acquire orderings for my variables since generally IMO one should only used relaxed when it is quite obviously the right thing, and I don't think that's obvious here at all. I then also changed the flag for consistency. If this flag indicates that some work was done (as flags often do), then it really should use release/acquire.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-libs Relevant to the library team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

std thread::Thread::unpark test deadlocked when run under miri
4 participants