Date: Tue, 21 Feb 2023 17:29:45 -0800
On Tuesday, 21 February 2023 16:02:11 PST Frederick Virchanza Gotham via Std-
Proposals wrote:
> I think 'lock_guard' and 'unique_lock' should be usable with atomic_flag.
Please don't use atomic_flag for locks, because:
> The constructor would do:
> while ( f.test_and_set() ) f.wait(true);
That is not a good implementation. It's neither a spinlock nor a futex.
You could argue that the constructor of this lock would Do The Right Thing.
The problem is that The Right Thing is to use a mutex, so just use a mutex or
a binary_semaphore.
Proposals wrote:
> I think 'lock_guard' and 'unique_lock' should be usable with atomic_flag.
Please don't use atomic_flag for locks, because:
> The constructor would do:
> while ( f.test_and_set() ) f.wait(true);
That is not a good implementation. It's neither a spinlock nor a futex.
You could argue that the constructor of this lock would Do The Right Thing.
The problem is that The Right Thing is to use a mutex, so just use a mutex or
a binary_semaphore.
-- Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org Software Architect - Intel DCAI Cloud Engineering
Received on 2023-02-22 01:29:47