]> git.llucax.com Git - software/eventxx.git/blobdiff - test/mixed-way.cpp
README: Add warning about project being abandoned
[software/eventxx.git] / test / mixed-way.cpp
index d9517a22f3d4f71ef0b5fc00cd3efd8f0caed514..f3238b2ddc0ca4df2c3baf7ea43a231eeba7dd6b 100644 (file)
@@ -2,15 +2,14 @@
 #include <iostream>
 #include <csignal>
 
 #include <iostream>
 #include <csignal>
 
-using eventxx::dispatcher;
-
 struct handler
 {
 struct handler
 {
-       dispatcher& d;
+       eventxx::dispatcher& d;
        int i;
        int i;
-       handler(dispatcher& d): d(d), i(0) {}
-       void operator() (int signum, short event)
+       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
                {
                if (i < 5) std::cout << "keep going...\n";
                else
                {
@@ -20,19 +19,18 @@ struct handler
        }
 };
 
        }
 };
 
-void sighandler(int signum, short event, void* data)
+void timer_handler(int, short, void*)
 {
 {
-       int& i = *static_cast< int* >(data);
-       std::cout << ++i << " interrupts, ";
+       std::cout << "Press Ctrl-C 5 times to quit.\n";
 }
 
 int main()
 {
 }
 
 int main()
 {
-       dispatcher d;
+       eventxx::dispatcher d;
        handler h(d);
        handler h(d);
-       eventxx::csignal sigev(SIGINT, sighandler, &h.i);
+       eventxx::ctimer t(timer_handler);
        eventxx::signal< handler > e(SIGINT, h);
        eventxx::signal< handler > e(SIGINT, h);
-       d.add(sigev);
+       d.add(t, eventxx::time(1)); // 1 second
        d.add(e);
        d.dispatch();
        return 0;
        d.add(e);
        d.dispatch();
        return 0;