eventxx  1.0.1
mixed-way.cpp

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;
handler(eventxx::dispatcher& d): d(d), i(0) {}
void operator() (int signum, eventxx::type event)
{
std::cout << ++i << " interrupts, ";
if (i < 5) std::cout << "keep going...\n";
else
{
std::cout << "done!\n";
d.exit();
}
}
};
void timer_handler(int, short, void*)
{
std::cout << "Press Ctrl-C 5 times to quit.\n";
}
int main()
{
handler h(d);
eventxx::ctimer t(timer_handler);
d.add(t, eventxx::time(1)); // 1 second
d.add(e);
d.dispatch();
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