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

Add pika::wait #704

Merged
merged 1 commit into from
Jul 12, 2023
Merged
Show file tree
Hide file tree
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
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