Hacker News new | past | comments | ask | show | jobs | submit login

I think the reason it's not a compile-time error is that it's actually possible to select your ordering at runtime, like this:

    use std::sync::atomic::*;
    let x = AtomicU64::new(0);
    let ordering = if rand::random() {
        Ordering::Relaxed
    } else {
        Ordering::SeqCst
    };
    x.fetch_add(1, ordering);



Yes, I tried (a few months ago) mocking a PR for this that refactored the enum variants into ZST structs and that was the only sticking point for backwards compatibility.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: