|
14 | 14 | #if defined(HPX_HAVE_CXX26_REFLECTION) |
15 | 15 |
|
16 | 16 | #include <hpx/actions_base/basic_action.hpp> |
| 17 | +#include <hpx/actions_base/detail/invocation_count_registry.hpp> |
17 | 18 | #include <hpx/actions_base/plain_action.hpp> |
18 | 19 | #include <hpx/modules/serialization.hpp> |
19 | 20 |
|
@@ -46,13 +47,16 @@ namespace hpx::actions { |
46 | 47 | /// reflect_action<F> integrates with HPX's action system by inheriting |
47 | 48 | /// from basic_action<detail::plain_function, R(Ps...), reflect_action<F>>. |
48 | 49 | /// All properties are derived automatically from the reflected function F. |
| 50 | + /// Invocation count registration is automatic via a static member -- |
| 51 | + /// no HPX_REGISTER_ACTION call is needed for reflection-based actions. |
49 | 52 | /// |
50 | 53 | /// \tparam F A std::meta::info reflection of a free function. |
51 | | - template <std::meta::info F> |
| 54 | + /// \tparam Derived Derived type for CRTP extensibility (default: void). |
| 55 | + template <std::meta::info F, typename Derived = void> |
52 | 56 | struct reflect_action |
53 | 57 | : basic_action<hpx::actions::detail::plain_function, |
54 | 58 | typename detail::reflect_action_base<F>::func_type, |
55 | | - reflect_action<F>> |
| 59 | + detail::action_type_t<reflect_action<F, Derived>, Derived>> |
56 | 60 | { |
57 | 61 | /// The function type (e.g. int(double, double)) |
58 | 62 | using func_type = [:std::meta::type_of(F):]; |
@@ -81,12 +85,23 @@ namespace hpx::actions { |
81 | 85 | naming::address::component_type /*comptype*/, Ts&&... vs) |
82 | 86 | { |
83 | 87 | using base_t = basic_action<hpx::actions::detail::plain_function, |
84 | | - func_type, reflect_action<F>>; |
| 88 | + func_type, detail::action_type_t<reflect_action, Derived>>; |
85 | 89 | base_t::increment_invocation_count(); |
86 | 90 | return func_ptr(HPX_FORWARD(Ts, vs)...); |
87 | 91 | } |
| 92 | + |
| 93 | + /// Automatic invocation count registration -- eliminates the need |
| 94 | + /// for HPX_REGISTER_ACTION for reflection-based plain actions. |
| 95 | + static detail::register_action_invocation_count<reflect_action> |
| 96 | + invocation_count_registrar_; |
88 | 97 | }; |
89 | 98 |
|
| 99 | + /// \cond NOINTERNAL |
| 100 | + template <std::meta::info F, typename Derived> |
| 101 | + detail::register_action_invocation_count<reflect_action<F, Derived>> |
| 102 | + reflect_action<F, Derived>::invocation_count_registrar_; |
| 103 | + /// \endcond |
| 104 | + |
90 | 105 | } // namespace hpx::actions |
91 | 106 |
|
92 | 107 | #endif // HPX_HAVE_CXX26_REFLECTION |
0 commit comments