2
* ivykis, an event handling library
3
* Copyright (C) 2010 Lennert Buytenhek
4
* Dedicated to Marija Kulikova.
6
* This library is free software; you can redistribute it and/or modify
7
* it under the terms of the GNU Lesser General Public License version
8
* 2.1 as published by the Free Software Foundation.
10
* This library is distributed in the hope that it will be useful,
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
* GNU Lesser General Public License version 2.1 for more details.
15
* You should have received a copy of the GNU Lesser General Public
16
* License version 2.1 along with this library; if not, write to the
17
* Free Software Foundation, Inc., 51 Franklin Street - Fifth Floor,
18
* Boston, MA 02110-1301, USA.
28
static struct iv_event ev0;
29
static struct iv_timer tim0;
30
static struct iv_event ev1;
31
static struct iv_timer tim1;
33
static void got_ev0(void *_dummy)
35
printf("%p: got ev0, starting tim0\n", (void *)pthread_self());
38
tim0.expires = iv_now;
39
tim0.expires.tv_sec++;
40
iv_timer_register(&tim0);
43
static void got_tim0(void *_dummy)
45
printf("%p: tim0 expired, signaling ev1\n", (void *)pthread_self());
50
static void got_ev1(void *_dummy)
52
printf("%p: got ev1, starting tim1\n", (void *)pthread_self());
55
tim1.expires = iv_now;
56
tim1.expires.tv_sec++;
57
iv_timer_register(&tim1);
60
static void got_tim1(void *_dummy)
62
printf("%p: tim1 expired, signaling ev0\n", (void *)pthread_self());
67
static void *thread1(void *_dummy)
72
ev1.handler = got_ev1;
73
iv_event_register(&ev1);
76
tim1.handler = got_tim1;
90
ev0.handler = got_ev0;
91
iv_event_register(&ev0);
94
tim0.handler = got_tim0;
96
pthread_create(&foo, NULL, thread1, NULL);
99
tim0.expires = iv_now;
100
tim0.expires.tv_sec++;
101
iv_timer_register(&tim0);