]> git.llucax.com Git - software/eventxx.git/blob - test/c-way.cpp
Add doc subdirectory to .gitignore
[software/eventxx.git] / test / c-way.cpp
1 #include <eventxx>
2 #include <iostream>
3 #include <csignal>
4
5 eventxx::dispatcher d;
6
7 void sighandler(int signum, short event, void* data)
8 {
9         unsigned &i = *(unsigned*)data;
10         std::cout << ++i << " interrupts, ";
11         if (i < 5) std::cout << "keep going...\n";
12         else
13         {
14                 std::cout << "done!\n";
15                 d.exit();
16         }
17 }
18
19 int main()
20 {
21         int var = 0;
22         eventxx::csignal sigev(SIGINT, sighandler, &var);
23         d.add(sigev);
24         d.dispatch();
25         return 0;
26 }
27