omni::application::signal_handler::ignore
NAME

omni::application::signal_handler::ignore

A function of omni::application::signal_handler

#include <omni/application.hpp>
void omni::application::signal_handler::ignore(bool doignore)

SYNOPSIS

If set, the application will ignore any subsequent signals sent.

top

DESCRIPTION

If ignore is called with value of true then all signals sent to the application will be ignored until the function is called again with a value of false passed in. If a signal is sent while ignore is true, the last signal sent will still be set but no handlers will be invoked.

top

PARAMETERS

doignore - If true, application will ignore subsequent signals sent. A value of false will resume normal capture operations.

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

Since the signals can be raised on different threads, it is important to take care of any multi-threaded issues that might arise when using any of the signal handlers.

top


EXAMPLE

#include <omni/application>

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) {
            if (++count == 300) {
                omni::application::signal_handler::ignore(false);
                std::cout << "Will listen for the signal on app_signal" << std::endl;
                atch = false;
            }
        }
    }
}

int main(int argc, char* argv[])
{
    omni::application::signal_handler::attach(&app_signal);
    omni::application::signal_handler::ignore(true);
    std::cout << "Signal handler attached, but will ignore signals for ~3s" << std::endl;
    return omni::application::run(&app_run);
}
Visit the examples page for more.

top