Skip to content

actions_base: add auto-registration to reflect_action#7298

Merged
hkaiser merged 9 commits into
TheHPXProject:masterfrom
Priyanshi507:reflect-action-auto-register
May 28, 2026
Merged

actions_base: add auto-registration to reflect_action#7298
hkaiser merged 9 commits into
TheHPXProject:masterfrom
Priyanshi507:reflect-action-auto-register

Conversation

@Priyanshi507
Copy link
Copy Markdown
Contributor

Summary

reflect_action now automatically registers its invocation counter
via a static register_action_invocation_count member — eliminating
the need for HPX_REGISTER_ACTION for reflection-based plain actions.

Design

Follows HPX's existing auto-registration pattern already used by
register_action<Action> in register_action.hpp:

template <std::meta::info F>
struct reflect_action : basic_action<...> {
    // Auto-registers during static initialization
    static detail::register_action_invocation_count<reflect_action<F>>
        invocation_count_registrar_;
};

What's still needed

The explicit transfer_action<reflect_action<F>> instantiation
(for shared library export) still requires HPX_REGISTER_ACTION
in non-reflection builds. For reflection builds, users can omit
HPX_REGISTER_ACTION entirely.

Depends on

Checklist

  • I have added a new feature and have added tests to go along with it.

reflect_action now includes a static register_action_invocation_count
member that automatically registers the action's invocation counter
during static initialization — no HPX_REGISTER_ACTION call needed.

This follows HPX's existing auto-registration pattern (already used
by register_action<Action> in register_action.hpp) and eliminates
boilerplate for reflection-based plain actions.

The explicit transfer_action instantiation (for shared library export)
still requires HPX_REGISTER_ACTION for non-reflection builds, but
reflect_action users can omit it entirely.

Signed-off-by: Priyanshi507 <hiiuiuiabi@gmail.com>
@Priyanshi507 Priyanshi507 requested a review from hkaiser as a code owner May 27, 2026 12:57
Signed-off-by: Priyanshi507 <hiiuiuiabi@gmail.com>
@StellarBot
Copy link
Copy Markdown
Collaborator

Can one of the admins verify this patch?

Signed-off-by: Priyanshi507 <hiiuiuiabi@gmail.com>
@codacy-production
Copy link
Copy Markdown

codacy-production Bot commented May 27, 2026

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

Signed-off-by: Priyanshi507 <hiiuiuiabi@gmail.com>
Signed-off-by: Priyanshi507 <hiiuiuiabi@gmail.com>
Comment thread libs/full/actions_base/include/hpx/actions_base/reflect_action.hpp Outdated
Add Derived template parameter following the same pattern as
plain_action for future extensibility:

  template <std::meta::info F, typename Derived = void>
  struct reflect_action
    : basic_action<detail::plain_function,
          func_type,
          detail::action_type_t<reflect_action<F, Derived>, Derived>>

This allows user-defined types to derive from reflect_action<F>
to customize behavior, matching the extensibility of make_action_t.

Signed-off-by: Priyanshi507 <hiiuiuiabi@gmail.com>
…strar_

Both the in-class declaration and out-of-class definition of
invocation_count_registrar_ now consistently use reflect_action<F, Derived>.

Signed-off-by: Priyanshi507 <hiiuiuiabi@gmail.com>
…trar_

Signed-off-by: Priyanshi507 <hiiuiuiabi@gmail.com>
hkaiser
hkaiser previously approved these changes May 27, 2026
Copy link
Copy Markdown
Contributor

@hkaiser hkaiser left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Otherwise, LGTM, thanks!

Comment thread libs/full/actions_base/include/hpx/actions_base/reflect_action.hpp Outdated
Comment thread libs/full/actions_base/include/hpx/actions_base/reflect_action.hpp Outdated
@hkaiser hkaiser added this to the 2.0.0 milestone May 27, 2026
Inside reflect_action's class body, 'reflect_action' refers to
'reflect_action<F, Derived>' via the injected class name, so
we can simplify:
- action_type_t<reflect_action<F, Derived>, Derived> -> action_type_t<reflect_action, Derived>
- register_action_invocation_count<reflect_action<F, Derived>> -> register_action_invocation_count<reflect_action>

Suggested by hkaiser.

Signed-off-by: Priyanshi507 <hiiuiuiabi@gmail.com>
Copy link
Copy Markdown
Contributor

@hkaiser hkaiser left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks!

@hkaiser hkaiser merged commit 275a67d into TheHPXProject:master May 28, 2026
73 checks passed
Priyanshi507 added a commit to Priyanshi507/hpx that referenced this pull request Jun 2, 2026
…t_action)

Summary
Extends reflect_action with reflect_component_action<F> — a C++26
reflection-based replacement for HPX_DEFINE_COMPONENT_ACTION.

Before (3 manual steps):
  HPX_DEFINE_COMPONENT_ACTION(server, compute, compute_action)
  HPX_REGISTER_ACTION_DECLARATION(compute_action)
  HPX_REGISTER_ACTION(compute_action)

After (single line):
  HPX_COMPONENT_ACTION(server, compute, compute_action);

Design
- reflect_component_action_base<F> extracts component_type via
  parent_of(F) and func_type via type_of(F) — two-step workaround
  following the same pattern as reflect_action_base<F>
- reflect_component_action<F, Derived> inherits from
  basic_action<component_type, func_type, action_type_t<...>>
- Auto-registration via static invocation_count_registrar_ member
  following the same pattern as reflect_action<F>
- HPX_COMPONENT_ACTION(component, func, name) macro as cross-compiler
  fallback (GCC trunk + Clang P2996)

Depends on
- PR TheHPXProject#7298 (merged) — reflect_action with Derived parameter

Signed-off-by: Priyanshi507 <hiiuiuiabi@gmail.com>
Priyanshi507 added a commit to Priyanshi507/hpx that referenced this pull request Jun 2, 2026
…t_action)

Summary
Extends reflect_action with reflect_component_action<F> — a C++26
reflection-based replacement for HPX_DEFINE_COMPONENT_ACTION.

Before (3 manual steps):
  HPX_DEFINE_COMPONENT_ACTION(server, compute, compute_action)
  HPX_REGISTER_ACTION_DECLARATION(compute_action)
  HPX_REGISTER_ACTION(compute_action)

After (single line):
  HPX_COMPONENT_ACTION(server, compute, compute_action);

Design
- reflect_component_action_base<F> extracts component_type via
  parent_of(F) and func_type via type_of(F) — two-step workaround
  following the same pattern as reflect_action_base<F>
- reflect_component_action<F, Derived> inherits from
  basic_action<component_type, func_type, action_type_t<...>>
- Auto-registration via static invocation_count_registrar_ member
  following the same pattern as reflect_action<F>
- HPX_COMPONENT_ACTION(component, func, name) macro as cross-compiler
  fallback (GCC trunk + Clang P2996)

Depends on
- PR TheHPXProject#7298 (merged) — reflect_action with Derived parameter

Signed-off-by: Priyanshi507 <hiiuiuiabi@gmail.com>
Priyanshi507 added a commit to Priyanshi507/hpx that referenced this pull request Jun 3, 2026
…t_action)

Summary
Extends reflect_action with reflect_component_action<F> — a C++26
reflection-based replacement for HPX_DEFINE_COMPONENT_ACTION.

Before (3 manual steps):
  HPX_DEFINE_COMPONENT_ACTION(server, compute, compute_action)
  HPX_REGISTER_ACTION_DECLARATION(compute_action)
  HPX_REGISTER_ACTION(compute_action)

After (single line):
  HPX_COMPONENT_ACTION(server, compute, compute_action);

Design
- reflect_component_action_base<F> extracts component_type via
  parent_of(F) and func_type via type_of(F) — two-step workaround
  following the same pattern as reflect_action_base<F>
- reflect_component_action<F, Derived> inherits from
  basic_action<component_type, func_type, action_type_t<...>>
- Auto-registration via static invocation_count_registrar_ member
  following the same pattern as reflect_action<F>
- HPX_COMPONENT_ACTION(component, func, name) macro as cross-compiler
  fallback (GCC trunk + Clang P2996)

Depends on
- PR TheHPXProject#7298 (merged) — reflect_action with Derived parameter

Signed-off-by: Priyanshi507 <hiiuiuiabi@gmail.com>
Priyanshi507 added a commit to Priyanshi507/hpx that referenced this pull request Jun 3, 2026
…t_action)

Summary
Extends reflect_action with reflect_component_action<F> — a C++26
reflection-based replacement for HPX_DEFINE_COMPONENT_ACTION.

Before (3 manual steps):
  HPX_DEFINE_COMPONENT_ACTION(server, compute, compute_action)
  HPX_REGISTER_ACTION_DECLARATION(compute_action)
  HPX_REGISTER_ACTION(compute_action)

After (single line):
  HPX_COMPONENT_ACTION(server, compute, compute_action);

Design
- reflect_component_action_base<F> extracts component_type via
  parent_of(F) and func_type via type_of(F) — two-step workaround
  following the same pattern as reflect_action_base<F>
- reflect_component_action<F, Derived> inherits from
  basic_action<component_type, func_type, action_type_t<...>>
- Auto-registration via static invocation_count_registrar_ member
  following the same pattern as reflect_action<F>
- HPX_COMPONENT_ACTION(component, func, name) macro as cross-compiler
  fallback (GCC trunk + Clang P2996)

Depends on
- PR TheHPXProject#7298 (merged) — reflect_action with Derived parameter

Signed-off-by: Priyanshi507 <hiiuiuiabi@gmail.com>
Priyanshi507 added a commit to Priyanshi507/hpx that referenced this pull request Jun 3, 2026
…t_action)

Summary
Extends reflect_action with reflect_component_action<F> — a C++26
reflection-based replacement for HPX_DEFINE_COMPONENT_ACTION.

Before (3 manual steps):
  HPX_DEFINE_COMPONENT_ACTION(server, compute, compute_action)
  HPX_REGISTER_ACTION_DECLARATION(compute_action)
  HPX_REGISTER_ACTION(compute_action)

After (single line):
  HPX_COMPONENT_ACTION(server, compute, compute_action);

Design
- reflect_component_action_base<F> extracts component_type via
  parent_of(F) and func_type via type_of(F) — two-step workaround
  following the same pattern as reflect_action_base<F>
- reflect_component_action<F, Derived> inherits from
  basic_action<component_type, func_type, action_type_t<...>>
- Auto-registration via static invocation_count_registrar_ member
  following the same pattern as reflect_action<F>
- HPX_COMPONENT_ACTION(component, func, name) macro as cross-compiler
  fallback (GCC trunk + Clang P2996)

Depends on
- PR TheHPXProject#7298 (merged) — reflect_action with Derived parameter

Signed-off-by: Priyanshi507 <hiiuiuiabi@gmail.com>
Priyanshi507 added a commit to Priyanshi507/hpx that referenced this pull request Jun 3, 2026
…t_action)

Summary
Extends reflect_action with reflect_component_action<F> — a C++26
reflection-based replacement for HPX_DEFINE_COMPONENT_ACTION.

Before (3 manual steps):
  HPX_DEFINE_COMPONENT_ACTION(server, compute, compute_action)
  HPX_REGISTER_ACTION_DECLARATION(compute_action)
  HPX_REGISTER_ACTION(compute_action)

After (single line):
  HPX_COMPONENT_ACTION(server, compute, compute_action);

Design
- reflect_component_action_base<F> extracts component_type via
  parent_of(F) and func_type via type_of(F) — two-step workaround
  following the same pattern as reflect_action_base<F>
- reflect_component_action<F, Derived> inherits from
  basic_action<component_type, func_type, action_type_t<...>>
- Auto-registration via static invocation_count_registrar_ member
  following the same pattern as reflect_action<F>
- HPX_COMPONENT_ACTION(component, func, name) macro as cross-compiler
  fallback (GCC trunk + Clang P2996)

Depends on
- PR TheHPXProject#7298 (merged) — reflect_action with Derived parameter

Signed-off-by: Priyanshi507 <hiiuiuiabi@gmail.com>
Priyanshi507 added a commit to Priyanshi507/hpx that referenced this pull request Jun 4, 2026
…t_action)

Summary
Extends reflect_action with reflect_component_action<F> — a C++26
reflection-based replacement for HPX_DEFINE_COMPONENT_ACTION.

Before (3 manual steps):
  HPX_DEFINE_COMPONENT_ACTION(server, compute, compute_action)
  HPX_REGISTER_ACTION_DECLARATION(compute_action)
  HPX_REGISTER_ACTION(compute_action)

After (single line):
  HPX_COMPONENT_ACTION(server, compute, compute_action);

Design
- reflect_component_action_base<F> extracts component_type via
  parent_of(F) and func_type via type_of(F) — two-step workaround
  following the same pattern as reflect_action_base<F>
- reflect_component_action<F, Derived> inherits from
  basic_action<component_type, func_type, action_type_t<...>>
- Auto-registration via static invocation_count_registrar_ member
  following the same pattern as reflect_action<F>
- HPX_COMPONENT_ACTION(component, func, name) macro as cross-compiler
  fallback (GCC trunk + Clang P2996)

Depends on
- PR TheHPXProject#7298 (merged) — reflect_action with Derived parameter

Signed-off-by: Priyanshi507 <hiiuiuiabi@gmail.com>
Priyanshi507 added a commit to Priyanshi507/hpx that referenced this pull request Jun 4, 2026
…t_action)

Summary
Extends reflect_action with reflect_component_action<F> — a C++26
reflection-based replacement for HPX_DEFINE_COMPONENT_ACTION.

Before (3 manual steps):
  HPX_DEFINE_COMPONENT_ACTION(server, compute, compute_action)
  HPX_REGISTER_ACTION_DECLARATION(compute_action)
  HPX_REGISTER_ACTION(compute_action)

After (single line):
  HPX_COMPONENT_ACTION(server, compute, compute_action);

Design
- reflect_component_action_base<F> extracts component_type via
  parent_of(F) and func_type via type_of(F) — two-step workaround
  following the same pattern as reflect_action_base<F>
- reflect_component_action<F, Derived> inherits from
  basic_action<component_type, func_type, action_type_t<...>>
- Auto-registration via static invocation_count_registrar_ member
  following the same pattern as reflect_action<F>
- HPX_COMPONENT_ACTION(component, func, name) macro as cross-compiler
  fallback (GCC trunk + Clang P2996)

Depends on
- PR TheHPXProject#7298 (merged) — reflect_action with Derived parameter

Signed-off-by: Priyanshi507 <hiiuiuiabi@gmail.com>
Priyanshi507 added a commit to Priyanshi507/hpx that referenced this pull request Jun 4, 2026
…t_action)

Summary
Extends reflect_action with reflect_component_action<F> — a C++26
reflection-based replacement for HPX_DEFINE_COMPONENT_ACTION.

Before (3 manual steps):
  HPX_DEFINE_COMPONENT_ACTION(server, compute, compute_action)
  HPX_REGISTER_ACTION_DECLARATION(compute_action)
  HPX_REGISTER_ACTION(compute_action)

After (single line):
  HPX_COMPONENT_ACTION(server, compute, compute_action);

Design
- reflect_component_action_base<F> extracts component_type via
  parent_of(F) and func_type via type_of(F) — two-step workaround
  following the same pattern as reflect_action_base<F>
- reflect_component_action<F, Derived> inherits from
  basic_action<component_type, func_type, action_type_t<...>>
- Auto-registration via static invocation_count_registrar_ member
  following the same pattern as reflect_action<F>
- HPX_COMPONENT_ACTION(component, func, name) macro as cross-compiler
  fallback (GCC trunk + Clang P2996)

Depends on
- PR TheHPXProject#7298 (merged) — reflect_action with Derived parameter

Signed-off-by: Priyanshi507 <hiiuiuiabi@gmail.com>
Priyanshi507 added a commit to Priyanshi507/hpx that referenced this pull request Jun 4, 2026
…t_action)

Summary
Extends reflect_action with reflect_component_action<F> — a C++26
reflection-based replacement for HPX_DEFINE_COMPONENT_ACTION.

Before (3 manual steps):
  HPX_DEFINE_COMPONENT_ACTION(server, compute, compute_action)
  HPX_REGISTER_ACTION_DECLARATION(compute_action)
  HPX_REGISTER_ACTION(compute_action)

After (single line):
  HPX_COMPONENT_ACTION(server, compute, compute_action);

Design
- reflect_component_action_base<F> extracts component_type via
  parent_of(F) and func_type via type_of(F) — two-step workaround
  following the same pattern as reflect_action_base<F>
- reflect_component_action<F, Derived> inherits from
  basic_action<component_type, func_type, action_type_t<...>>
- Auto-registration via static invocation_count_registrar_ member
  following the same pattern as reflect_action<F>
- HPX_COMPONENT_ACTION(component, func, name) macro as cross-compiler
  fallback (GCC trunk + Clang P2996)

Depends on
- PR TheHPXProject#7298 (merged) — reflect_action with Derived parameter

Signed-off-by: Priyanshi507 <hiiuiuiabi@gmail.com>
Priyanshi507 added a commit to Priyanshi507/hpx that referenced this pull request Jun 4, 2026
…t_action)

Summary
Extends reflect_action with reflect_component_action<F> — a C++26
reflection-based replacement for HPX_DEFINE_COMPONENT_ACTION.

Before (3 manual steps):
  HPX_DEFINE_COMPONENT_ACTION(server, compute, compute_action)
  HPX_REGISTER_ACTION_DECLARATION(compute_action)
  HPX_REGISTER_ACTION(compute_action)

After (single line):
  HPX_COMPONENT_ACTION(server, compute, compute_action);

Design
- reflect_component_action_base<F> extracts component_type via
  parent_of(F) and func_type via type_of(F) — two-step workaround
  following the same pattern as reflect_action_base<F>
- reflect_component_action<F, Derived> inherits from
  basic_action<component_type, func_type, action_type_t<...>>
- Auto-registration via static invocation_count_registrar_ member
  following the same pattern as reflect_action<F>
- HPX_COMPONENT_ACTION(component, func, name) macro as cross-compiler
  fallback (GCC trunk + Clang P2996)

Depends on
- PR TheHPXProject#7298 (merged) — reflect_action with Derived parameter

Signed-off-by: Priyanshi507 <hiiuiuiabi@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants