Hi Frederick,

 

you should compare the typing effort to predefined classes offering this functionality (probably one line for defining the static mutex variable and another one for the lock guard at the usage location) instead of comparing it to the full code. But it is good that you have presented the full code here.

 

As you saw there are lots of combinations, one could wish for, which more speaks for a feature with (possibly standard) library support than for a language feature.

In the future even more combinations could be needed: You assume that all threads are equal, but you could have thread groups, e.g. those running on certain cores, processors, ... the clear industry trend goes to more processor cores (e.g. have a look at https://en.wikipedia.org/wiki/Non-uniform_memory_access#/media/File:Hwloc.png). You got feedback on this list that there are also different solutions how to lock threads with differing performance characteristics.

 

One could also try to keep the introduced feature totally flexible (and make it even general for other usages), but at the same type reduce the typing effort by either

 - Being able to define a static and a non-static variable in one line (somehow as class) or

 - Metaprogramming/Metaclasses approaches, where classes and functions can be expanded and changed by compile-time code according to parameters/annotations

 

Best,
Sebastian

 

-----Ursprüngliche Nachricht-----
Von: Frederick Virchanza Gotham via Std-Proposals <std-proposals@lists.isocpp.org>
Gesendet: Di 14.02.2023 11:52
Betreff: Re: [std-proposals] int Func(void) noreentry(-1)
An: std-proposals@lists.isocpp.org;
CC: Frederick Virchanza Gotham <cauldwell.thomas@gmail.com>;
On Tue, Feb 14, 2023 at 9:32 AM Frederick Virchanza Gotham wrote:

I want to show just how much typing this would save. The following code snippet: