Skip to content

Commit

Permalink
Merge pull request #2106 from DARMA-tasking/2091-missing-return-state…
Browse files Browse the repository at this point in the history
…ment

2091: fix `missing return statement` warning
  • Loading branch information
PhilMiller authored Mar 21, 2023
2 parents 2d0440b + f3d2f04 commit 6da9a8c
Showing 1 changed file with 13 additions and 10 deletions.
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();
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

0 comments on commit 6da9a8c

Please sign in to comment.