omni::application::signal_handler::callback
NAME

omni::application::signal_handler::callback

A typedef of omni::application::signal_handler

#include <omni/application.hpp>
typedef omni::delegate1<void, int> omni::application::signal_handler::callback

SYNOPSIS

Defines the signal handler function signature; that of void signal_handler(int sig)

top

DESCRIPTION

The callback function handler can be used to bind directly to a signal handler function, or you can simply pass the address of a static function to the handler functions.

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


EXAMPLE

#include <omnilib>

static volatile bool dorun = true;

void app_signal(int sig)
{
    std::cout << "Signal received: " << sig << std::endl;
    dorun = false;
}

void other_app_sig(int sig)
{
    std::cout << "Other signal: " << sig << std::endl;
    dorun = false;
}

void app_run()
{
    while (dorun) {
        omni::sync::sleep(10); // small sleep
    }
}

int main(int argc, char* argv[])
{
    omni::application::signal_handler::callback cb = &app_signal;
    if (argc > 3) { cb = &other_app_sig; }
    omni::application::signal_handler::attach(cb);
    return omni::application::run(&app_run);
}
Visit the examples page for more.

top