C++ Logo

std-proposals

Advanced search

Re: [std-proposals] int Func(void) noreentry(-1)

From: Frederick Virchanza Gotham <cauldwell.thomas_at_[hidden]>
Date: Tue, 14 Feb 2023 09:32:08 +0000
On Tue, Feb 14, 2023 at 9:12 AM Frederick Virchanza Gotham wrote:
>
> And finally, it could be possible to mark a member function both with
> "noreentry_this_object" and also "noreentry_all_objects", for example:
>
> void Func(void) noreentry_this_object(prevent_same_thread)
> noreentry_all_objects(prevent_same_thread,prevent_other_threads:wait)


Actually that combination doesn't make sense -- and so the compiler
should emit an diagnostic:

main.cpp:3:20: error: method in class marked both 'noreentry_this_object'
                      and 'noreentry_all_objects' but the combination
                      doesn't make sense
    3 | void Func(void) noreentry_this_object(prevent_same_thread)
      | ^~~~~~~~~~~~~~~~~~~
      |
noreentry_all_objects(prevent_same_thread,prevent_other_threads:wait)
      | ^~~~~~~~~~~~~~~~~~~

Here's a sensible combination:

      void Func(void)
noreentry_this_object(prevent_other_threads:skip)
noreentry_all_objects(prevent_other_threads:wait)

Whenever we have a combination of "noreentry_this_object" and
"noreentry_all_objects", here's how the compiler works:
* If the member function is currently entered for *this, the
"noreentry_all_objects" clause is ignored
* If the member function is currently entered but not for *this, then
the "noreentry_this_object" clause is ignored

Received on 2023-02-14 09:32:19