]> git.llucax.com Git - software/eventxx.git/blob - test/functor-way.cpp
Fix an implicit cast from const char* (string literal) to char*.
[software/eventxx.git] / test / functor-way.cpp
1 #include <eventxx>
2 #include <iostream>
3 #include <csignal>
4
5 using eventxx::dispatcher;
6
7 struct handler
8 {
9         dispatcher& d;
10         int i;
11         handler(dispatcher& d): d(d), i(0) {}
12         void operator() (int signum, eventxx::type event)
13         {
14                 std::cout << ++i << " interrupts, ";
15                 if (i < 5) std::cout << "keep going...\n";
16                 else
17                 {
18                         std::cout << "done!\n";
19                         d.exit();
20                 }
21         }
22 };
23
24 int main()
25 {
26         dispatcher d;
27         handler h(d);
28         eventxx::signal< handler > e(SIGINT, h);
29         d.add(e);
30         d.dispatch();
31         return 0;
32 }
33