hpx::finalize

hpx::finalize#

Defined in header hpx/init.hpp.

See Public API for a list of names and headers that are part of the public HPX API.

See also:

int hpx::finalize(hpx::error_code &ec = throws)#

Main function to gracefully terminate the HPX runtime system.

The function hpx::finalize is the main way to (gracefully) exit any HPX application. It must be called at least once, but can be called multiple times as well. However, only the first invocation will have effect. It will notify all connected localities to finish execution. Only after all other localities have exited this function will return, allowing to exit the console locality as well.

During the execution of this function the runtime system will invoke all registered shutdown functions (see hpx::init) on all localities.

This function will not wait for all connected localities to exit, rather it informs all connected localities that they should exit whenever there is no more work to be done.

Using this function is an alternative to hpx::disconnect, these functions do not need to be called both.

Note

As long as ec is not pre-initialized to hpx::throws this function doesn’t throw but returns the result code using the parameter ec. Otherwise, it throws an instance of hpx::exception.

Parameters:

ec – [in,out] this represents the error status on exit, if this is pre-initialized to hpx::throws the function will throw on error instead.

Returns:

This function will always return zero.

int hpx::finalize(hpx::chrono::steady_duration shutdown_timeout, hpx::error_code &ec = throws)#

Main function to gracefully terminate the HPX runtime system.

The function hpx::finalize is the main way to (gracefully) exit any HPX application. It must be called at least once, but can be called multiple times as well. However, only the first invocation will have effect. It will notify all connected localities to finish execution. Only after all other localities have exited this function will return, allowing to exit the console locality as well.

During the execution of this function the runtime system will invoke all registered shutdown functions (see hpx::init) on all localities.

Any std::chrono::duration is implicitly convertible to hpx::chrono::steady_duration, e.g. hpx::finalize(std::chrono::seconds(60)). Pass the timeout explicitly to use it; call the overload taking no arguments to use the globally configured default (see configuration parameter hpx.shutdown_timeout).

This function will not wait for all connected localities to exit, rather it informs all connected localities that they should exit whenever there is no more work to be done.

Using this function is an alternative to hpx::disconnect, these functions do not need to be called both.

Note

As long as ec is not pre-initialized to hpx::throws this function doesn’t throw but returns the result code using the parameter ec. Otherwise, it throws an instance of hpx::exception.

Parameters:
  • shutdown_timeout – This parameter allows to specify a timeout, specifying how long any of the connected localities should wait for pending tasks to be executed. After this timeout, all suspended HPX-threads will be aborted. Note, that this function will not abort any running HPX-threads. In any case the shutdown will not proceed as long as there is at least one pending/running HPX-thread.

  • ec – [in,out] this represents the error status on exit, if this is pre-initialized to hpx::throws the function will throw on error instead.

Returns:

This function will always return zero.

int hpx::finalize(double shutdown_timeout, double localwait, error_code &ec)#
int hpx::finalize(double shutdown_timeout, error_code &ec)#