omni::application::terminate_handler::attach

SYNOPSIS

Attach an omni::callback delegate to the terminate handler.

top

DESCRIPTION

If std::terminate is invoked after having called an omni::application::run context, any attached delegates will be invoked in the order they were attached.

Since the terminate handler deals specifically with handling the invocation of std::terminate, a call to attach can be made before or after the run context has been invoked and the handlers will be called accordingly.

top

PARAMETERS

terminate_func - The omni::callback delegate function to attach.

top

ERRORS

If an exception occurs on an attached delegate, it will be handled according to omni::sync::user_thread_exception and omni::sync::unhandled_thread_exception.

top

CONSIDERATIONS

This function will only have an effect if you have explicitly called one of the omni::application::run functions to block the main thread until program completion.

top

NOTES

Be aware that the std::atexit function will call any functions in the reverse order registered. So if omni::application::run is called after any other calls to register a function with std::atexit in user code, then the underlying exit handler event will be called accordingly in order attached; in other words, if you were to call std::atexit(&some_function) then shutdown_handler::attach(&some_func) and call omni::application::run, the Omni exit handler will be called first, then some_function last.

top