-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtesttimer.c
36 lines (34 loc) · 853 Bytes
/
testtimer.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#include <sys/stat.h>
#include <sys/time.h>
#include <fcntl.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <errno.h>
#include <event.h>
void time_cb(int fd, short event, void *arg)
{
struct timeval tv;
struct event *ev = NULL;
// add your code here
fprintf(stderr, "Hello, evtimer\n");
ev = malloc(sizeof(struct event));
tv.tv_sec = 0;
tv.tv_usec = 50000L;
evtimer_set(ev, time_cb, ev);
evtimer_add(ev, &tv);
}
int main(int argc, char *argv)
{
struct timeval tv;
struct event *ev = NULL;
event_init();
ev = malloc(sizeof(struct event));
tv.tv_sec = 0;
tv.tv_usec = 50000L;
evtimer_set(ev, time_cb, ev);
evtimer_add(ev, &tv);
event_dispatch();
return 0;
}