On Wednesday 3 July 2024 23:24:09 CEST 李 秋逸 via Std-Proposals wrote:
> Here is the impl in MSVC STL:
>
> //The only data member of std::binary_semaphore is atomic<unsigned char>
> _Counter void acquire() noexcept /* strengthened */ {
> for (;;) {
> unsigned char _Prev = _Counter.exchange(0);
> if (_Prev == 1) {
> break;
> }
> _Counter.wait(0, memory_order_relaxed);
> }
> }
>
> It will change to
>
> void acquire() noexcept
> {
> _Counter.wait_and_write_back(0);
> }
>
> Observely, there is less atomic calling and if in the function body of
> acquire.
Why do you say there's less atomic code? You've moved the implementation of
one function into another, but have not shown this produces better or safer
code.
--
Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
Principal Engineer - Intel DCAI Platform & System Engineering
--
Std-Proposals mailing list
Std-Proposals@lists.isocpp.org
https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals