Created on 2025-04-17.00:00:00 last changed 3 weeks ago
Both `compare_exchange_strong` and `compare_exchange_weak` share the same specified rule
If and only if the comparison is `false` then, after the atomic operation, the value in `expected` is replaced by the value read from the value referenced by `*ptr` during the atomic comparison.
However, there is a remark for the weak version
A weak compare-and-exchange operation may fail spuriously.
That is, even when the contents of memory referred to by `expected` and `ptr` are equal, it may return `false` and store back to expected the same memory contents that were originally there.
However, we don't explicitly say whether the strong version can have the spuriously failed comparison. The status quo is that we can only infer the point from the name, namely, the strong version should have a stronger guarantee than the weak version. Suggested resolution: Explicitly specify whether `compare_exchange_strong` can have the spurious failed comparison.History | |||
---|---|---|---|
Date | User | Action | Args |
2025-04-17 00:00:00 | admin | create |