C++ Logo

std-proposals

Advanced search

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

From: Marcin Jaczewski <marcinjaczewski86_at_[hidden]>
Date: Mon, 13 Feb 2023 19:54:06 +0100
pon., 13 lut 2023 o 18:20 Thiago Macieira via Std-Proposals
<std-proposals_at_[hidden]> napisaƂ(a):
>
> On Monday, 13 February 2023 09:09:06 PST Frederick Virchanza Gotham via Std-
> Proposals wrote:
> > Yes. If you have a Labrador object and invoke a member function
> > pointer to "Bark" on it then it will block. But if you apply this same
> > member function pointer to an object of type Dog or BlackLabrador,
> > then it won't block.
>
> This necessarily implies the solution is "callee blocks" (after call
> received), not "caller blocks" (before placing the call). In other words, the
> caller knows absolutely nothing about whether the callee will block or not,
> thereby also allowing pointers to such functions to be stored in regular,
> existing function pointers.
>
> But as a consequence, this means you have nothing more than syntactic sugar to
> implement a mutex, even though it must be in the class layout.
>
> Because the mutex is hidden, it also prevents reordering them to optimise
> member access, prevent false cacheline sharing, or sharing the mutexes between
> multiple functions that may need to block any and all of them. That makes it
> impossible to move said mutex to a private-implementation class so that they
> can be added or removed at will without changing the public class and
> retaining binary compatibility. It also prevents early releasing of the mutex
> when the contention has been dealt with, or late acquisition of the mutex
> after input validation.
>
> Please address these concerns in your paper.
>

This feature is probably too specific to be included to standard but
the idea of "altering"
function by mixing some logic could be useful in many other cases.

In some future version there will be static reflection available in C++, then
why not make reflection be able to implement logic like this?

```
struct Foo apply_reflect(addHiddenMember)
{
    int bar() apply_reflect(useHiddenMember)
    {
      return 42;
    }
};
```

I recall that Rust has functionality like this.


> --
> Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
> Software Architect - Intel DCAI Cloud Engineering
>
>
>
> --
> Std-Proposals mailing list
> Std-Proposals_at_[hidden]
> https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals

Received on 2023-02-13 18:54:18