Fixing core.atomic
Max Haughton
maxhaton at gmail.com
Mon May 31 21:23:17 UTC 2021
On Monday, 31 May 2021 at 21:08:37 UTC, Ola Fosheim Grøstad wrote:
> On Monday, 31 May 2021 at 21:01:35 UTC, Max Haughton wrote:
>>> https://en.cppreference.com/w/cpp/atomic/atomic_is_lock_free
>>>
>>> C/C++ is trying to be hardware-independent to a much larger
>>> extent than D.
>>
>> "Atomic types are also allowed to be sometimes lock-free"
>
> Yes, that is what the trait is for?
>
> But with the limited hardware scope D has it surely can provide
> more convenient guarantees than C++ can?
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.
More information about the Digitalmars-d
mailing list