diff --git a/libs/pika/init_runtime/include/pika/init_runtime/init_runtime.hpp b/libs/pika/init_runtime/include/pika/init_runtime/init_runtime.hpp index 78971d76a..b2d36f63d 100644 --- a/libs/pika/init_runtime/include/pika/init_runtime/init_runtime.hpp +++ b/libs/pika/init_runtime/include/pika/init_runtime/init_runtime.hpp @@ -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 diff --git a/libs/pika/init_runtime/src/init_runtime.cpp b/libs/pika/init_runtime/src/init_runtime.cpp index a1d573536..c6e9c9077 100644 --- a/libs/pika/init_runtime/src/init_runtime.cpp +++ b/libs/pika/init_runtime/src/init_runtime.cpp @@ -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())