X-Git-Url: https://git.llucax.com/software/eventxx.git/blobdiff_plain/74dd493396de3a10431274f3a96f660b7eb7483c..HEAD:/test/mixed-way.cpp?ds=inline diff --git a/test/mixed-way.cpp b/test/mixed-way.cpp index daea2e6..f3238b2 100644 --- a/test/mixed-way.cpp +++ b/test/mixed-way.cpp @@ -9,6 +9,7 @@ struct handler 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 { @@ -18,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() { eventxx::dispatcher d; handler h(d); - eventxx::csignal sigev(SIGINT, sighandler, &h.i); + eventxx::ctimer t(timer_handler); eventxx::signal< handler > e(SIGINT, h); - d.add(sigev); + d.add(t, eventxx::time(1)); // 1 second d.add(e); d.dispatch(); return 0;