[–] chen_dev 2y ago ↗ > People sometimes think that the composition of atomics also magically becomes an atomic operation. But this is not the case.> var counter atomic.Int32> func increment() {> if counter.Load()%2 == 0 {> sleep(10)> counter.Add(1)> } else {> sleep(10)> counter.Add(2)> }> }Is "atomic operations composition" a real term? Or it's something like "monolithic microservice"? What does that even mean? [–] BobbyJo 2y ago ↗ > Is "atomic operations composition" a real term? Or it's something like "monolithic microservice"? What does that even mean?Its a real term in the sense that it's a grammatically correct way of describing multiple atomic operations being composed together...
[–] BobbyJo 2y ago ↗ > Is "atomic operations composition" a real term? Or it's something like "monolithic microservice"? What does that even mean?Its a real term in the sense that it's a grammatically correct way of describing multiple atomic operations being composed together...
[–] [dead] tiziano88 2y ago ↗ [flagged] [–] chen_dev 2y ago ↗ 1) what#![allow(unused)]fn main() { use std::sync::atomic::{AtomicI64, Ordering}; let some_var = AtomicI64::new(5); if some_var.load(Ordering::Relaxed) % 2 == 0 { some_var.fetch_add(1, Ordering::Relaxed); } else { some_var.fetch_add(2, Ordering::Relaxed); } }
[–] chen_dev 2y ago ↗ 1) what#![allow(unused)]fn main() { use std::sync::atomic::{AtomicI64, Ordering}; let some_var = AtomicI64::new(5); if some_var.load(Ordering::Relaxed) % 2 == 0 { some_var.fetch_add(1, Ordering::Relaxed); } else { some_var.fetch_add(2, Ordering::Relaxed); } }
5 comments
[ 3.4 ms ] story [ 7.6 ms ] thread> var counter atomic.Int32
> func increment() {
> if counter.Load()%2 == 0 {
> sleep(10)
> counter.Add(1)
> } else {
> sleep(10)
> counter.Add(2)
> }
> }
Is "atomic operations composition" a real term? Or it's something like "monolithic microservice"? What does that even mean?
Its a real term in the sense that it's a grammatically correct way of describing multiple atomic operations being composed together...
#![allow(unused)]
fn main() {