Skip to content

Commit

Permalink
Merge pull request #704 from msimberg/pika-wait
Browse files Browse the repository at this point in the history
Add `pika::wait`
  • Loading branch information
msimberg authored Jul 12, 2023
2 parents 03156cd + c7fcdf5 commit 419e357
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ namespace pika {
init_params const& params = init_params());
PIKA_EXPORT int finalize(error_code& ec = throws);
PIKA_EXPORT int stop(error_code& ec = throws);
PIKA_EXPORT int wait(error_code& ec = throws);
PIKA_EXPORT int suspend(error_code& ec = throws);
PIKA_EXPORT int resume(error_code& ec = throws);
} // namespace pika
15 changes: 15 additions & 0 deletions libs/pika/init_runtime/src/init_runtime.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,21 @@ namespace pika {
return result;
}

int wait(error_code& ec)
{
runtime* rt = get_runtime_ptr();
if (nullptr == rt)
{
PIKA_THROWS_IF(ec, pika::error::invalid_status, "pika::wait",
"the runtime system is not active (did you already call pika::stop?)");
return -1;
}

rt->get_thread_manager().wait();

return 0;
}

int suspend(error_code& ec)
{
if (threads::detail::get_self_ptr())
Expand Down

0 comments on commit 419e357

Please sign in to comment.