Date: Wed, 15 Feb 2023 10:37:18 +0000
On Wed, Feb 15, 2023 at 6:47 AM Thiago Macieira wrote:
>>
> > In my 3 or 4 emails earlier today I used an 'std::atomic_flag' for this job.
>
> atomic_flag is unlikely to be the correct solution. A mutex would is more likely.
The two standard library types, mutex and recursive_mutex, can prevent
re-entry by a different thread. They cannot prevent re-entry by the
same thread.
I'm proposing that writing "noreentry" after the name of a function
can prevent re-entry by the same thread (and also by other threads).
A recursive_mutex will work fine if you don't need to restrict
re-entry by the same thread, but you need an atomic_flag to prevent
re-entry by the same thread.
>>
> > In my 3 or 4 emails earlier today I used an 'std::atomic_flag' for this job.
>
> atomic_flag is unlikely to be the correct solution. A mutex would is more likely.
The two standard library types, mutex and recursive_mutex, can prevent
re-entry by a different thread. They cannot prevent re-entry by the
same thread.
I'm proposing that writing "noreentry" after the name of a function
can prevent re-entry by the same thread (and also by other threads).
A recursive_mutex will work fine if you don't need to restrict
re-entry by the same thread, but you need an atomic_flag to prevent
re-entry by the same thread.
Received on 2023-02-15 10:37:29