Skip to content

SC: Make timed_run() a unified templated function for void and non-void return types#42

Merged
linh2931 merged 2 commits intosync_callfrom
timed_run_return_result
May 16, 2025
Merged

SC: Make timed_run() a unified templated function for void and non-void return types#42
linh2931 merged 2 commits intosync_callfrom
timed_run_return_result

Conversation

@linh2931
Copy link
Contributor

@linh2931 linh2931 commented May 16, 2025

Change Description

timed_run() is used in Spring for executing apply() and sync_call() entry points. apply() is a void while sync_call() returns int64_t.

With C++ template function traits, it is elegant to make a single timed_run() for both void and non-void return types.

Resolves #41

API Changes

  • API Changes

Documentation Additions

  • Documentation Additions

@linh2931 linh2931 requested review from heifner and spoonincode May 16, 2025 17:09
std::forward<F>(f)();

using return_type = std::invoke_result_t<F>;
if constexpr (std::is_void_v<return_type>) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm suspicious this check isn't actually required.

Copy link
Contributor

Choose a reason for hiding this comment

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

yeah I tried and replacing all this with just return std::forward<F>(f)(); compiled okay (on spring's return_status branch)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks! You are correct. It is now even cleaner.

@linh2931 linh2931 merged commit 3cf396e into sync_call May 16, 2025
10 checks passed
@linh2931 linh2931 deleted the timed_run_return_result branch May 16, 2025 18:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants