NAME
A function of omni::application::signal_handler
omni::application::signal_handler::detach
A function of omni::application::signal_handler
#include <omni/application.hpp>void omni::application::signal_handler::detach(const omni::application::signal_handler::callback& sig_func)
DESCRIPTION
Detaching a specific delegate will stop that function from receiving system signal events. Detaching a delegate that has not been initially attached has no effect.
top
Detaching a specific delegate will stop that function from receiving system signal events. Detaching a delegate that has not been initially attached has no effect.
top
PARAMETERS
top
sig_func - The omni::application::signal_handler::callback function delegate to detach from the signal handler event.
top
CONSIDERATIONS
This function will only have an effect if you have explicitly called one of the
top
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
PLATFORM SPECIFIC
On Windows based platforms, this will also detach from the system signal events (as described), as well as the console control handler.
top
On Windows based platforms, this will also detach from the system signal events (as described), as well as the console control handler.
top
EXAMPLE
Visit the examples page for more.
top
#include <omnilib> static volatile bool dorun = true; void app_signal(int sig) { std::cout << "Signal received: " << sig << std::endl; dorun = false; } void app_run() { int count = 0; bool atch = true; while (dorun) { omni::sync::sleep(10); // small sleep if (atch && ++count > 10) { atch = false; omni::application::signal_handler::detach(&app_signal); std::cout << "Will not receive the signal on app_signal" << std::endl; } } } int main(int argc, char* argv[]) { omni::application::signal_handler::attach(&app_signal); return omni::application::run(&app_run); }
top