Date: Tue, 14 Feb 2023 16:35:27 +0000
On Tue, Feb 14, 2023 at 3:15 PM Thiago Macieira via Std-Proposals
<std-proposals_at_[hidden]> wrote:
>>
> > struct Monkey {
> > void Func(void) noreentry_this_object(prevent_other_threads:skip)
> >
> > noreentry_all_objects(prevent_other_threads:wait)
> > {
> > // Main body of function goes here
> > }
> > };
>
> How about with a recursive mutex?
In this particular example, there is no prevention on "same thread"
and so at first glance a 'recursive_mutex' comes to mind. For the
'skipping' part, we'd have to use 'try_lock' on the recursive_mutex.
If we also prevent the 'same thread' though, a recursive mutex won't
prevent re-entry.
In my 3 or 4 emails earlier today I used an 'std::atomic_flag' for this job.
<std-proposals_at_[hidden]> wrote:
>>
> > struct Monkey {
> > void Func(void) noreentry_this_object(prevent_other_threads:skip)
> >
> > noreentry_all_objects(prevent_other_threads:wait)
> > {
> > // Main body of function goes here
> > }
> > };
>
> How about with a recursive mutex?
In this particular example, there is no prevention on "same thread"
and so at first glance a 'recursive_mutex' comes to mind. For the
'skipping' part, we'd have to use 'try_lock' on the recursive_mutex.
If we also prevent the 'same thread' though, a recursive mutex won't
prevent re-entry.
In my 3 or 4 emails earlier today I used an 'std::atomic_flag' for this job.
Received on 2023-02-14 16:35:39