Fixing core.atomic
Ola Fosheim Grøstad
ola.fosheim.grostad at gmail.com
Mon May 31 21:38:25 UTC 2021
On Monday, 31 May 2021 at 21:23:17 UTC, Max Haughton wrote:
> This is orthogonal to the example I posted, what if the
> hardware can't perform the operation using simple atomic
> instructions, you might as well provide the fallback case
> anyway - both for easier correctness and to kill two birds with
> one API. Guaranteeing that the type uses the instructions
> anyway is up to the implementation, but the guarantee can be
> made nonetheless.
I am not sure I understand what you mean now. Locking operations
may imply completely different algorithms.
In C++ you can either do a static compile time check using
```is_always_lock_free``` or a dynamic runtime check (then take
an alternative path if it isn't). The dynamic check is to allow
higher performance when it can be used, but that might require a
completely different algorithm?
Or with C++20 you have optional
```atomic_signed_lock_free``` and
```atomic_unsigned_lock_free```, which I probably will use when I
get them.
More information about the Digitalmars-d
mailing list