Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

2091: fix missing return statement warning #2106

Merged
merged 2 commits into from
Mar 21, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 13 additions & 10 deletions src/vt/runnable/runnable.h
Original file line number Diff line number Diff line change
Expand Up @@ -235,16 +235,19 @@ struct RunnableNew {
decltype(auto) runLambda(Callable&& c, Args&&... args) {
auto start_time = timing::getCurrentTime();
start(start_time);
if constexpr(std::is_void_v<std::invoke_result_t<Callable, Args...>>) {
std::invoke(std::forward<Callable>(c), std::forward<Args>(args)...);
auto finish_time = timing::getCurrentTime();
finish(finish_time);
} else {
decltype(auto) r{std::invoke(std::forward<Callable>(c), std::forward<Args>(args)...)};
auto finish_time = timing::getCurrentTime();
finish(finish_time);
return r;
}

// Arrange a scope guard to call finish() without any sort of dynamic allocation
struct finisher {
RunnableNew* r;
finisher(RunnableNew* in_r) : r(in_r){};
~finisher() {
auto finish_time = timing::getCurrentTime();
cz4rs marked this conversation as resolved.
Show resolved Hide resolved
r->finish(finish_time);
}
};
finisher f(this);

return std::invoke(std::forward<Callable>(c), std::forward<Args>(args)...);
}

#if vt_check_enabled(fcontext)
Expand Down