3 ms·
> The "fix" in C11 is to just say we have the C++ 11 Memory Ordering Model and here are some built-ins for the ordered atomic operations that implies. Isn't Ru
by designuki 1mo ago
> The "fix" in C11 is to just say we have the C++ 11 Memory Ordering Model and here are some built-ins for the ordered atomic operations that implies.
Isn't Rust's solution mostly the same, just with C++20?
https://doc.rust-lang.org/nomicon/atomics.html https://doc.rust-lang.org/nomicon/atomics.html
> Rust pretty blatantly just inherits the memory model for atomics from C++20.
- tialaramex 1mo agoRust does have the same Memory Ordering idea (minus the ill-fated "Consume" ordering) but provides richer tools for a modern world than C does. The C standard library provides nothing to actually do concurrency, such as making more threads, nor to synchronize them, such as with a mutex whereas of course Rust provides std::thread::spawn and std::sync::Mutex In C this is a platform specific problem, for Unix systems you want pthreads for example while Windows provides a different arrangement. Rust does not provide out-of-the-box structured concurrency - which I would like - but it's a lot closer to what I'd prefer here.
- fanf2 1mo agoThe C standard library has had <threads.h> since C11 https://www.cppreference.com/c/thread https://www.cppreference.com/c/thread and there are now a nonzero number of systems that support it! (glibc, musl, maybe others?)
- tialaramex 1mo agoWell TIL. Thanks.