This is a simple example illustrating the usage with a mix of C-like callbacks and function object callbacks.
#include <eventxx>
#include <iostream>
#include <csignal>
struct handler
{
int i;
{
std::cout << ++i << " interrupts, ";
if (i < 5) std::cout << "keep going...\n";
else
{
std::cout << "done!\n";
}
}
};
void timer_handler(int, short, void*)
{
std::cout << "Press Ctrl-C 5 times to quit.\n";
}
int main()
{
handler h(d);
return 0;
}
type
Type of events.
Definition: eventxx:192
Event dispatcher.
Definition: eventxx:549
int dispatch(int flags=0)
Main dispatcher loop.
Definition: eventxx:764
int exit(const time &to=time())
Exit the dispatch() loop.
Definition: eventxx:778
void add(basic_event &e, int priority=DEFAULT_PRIORITY)
Adds an event to the dispatcher.
Definition: eventxx:588
Signal event object.
Definition: eventxx:425
Time used for timeout values.
Definition: eventxx:111
This is the specialization of eventxx::timer for C-style callbacks.
Definition: eventxx:395