Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(482)

Side by Side Diff: third_party/libevent/sample/time-test.c

Issue 1531573008: move libevent into base (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix shim path Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « third_party/libevent/sample/signal-test.c ('k') | third_party/libevent/select.c » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 /*
2 * Compile with:
3 * cc -I/usr/local/include -o time-test time-test.c -L/usr/local/lib -levent
4 */
5
6 #include <sys/types.h>
7
8 #ifdef HAVE_CONFIG_H
9 #include "config.h"
10 #endif
11
12 #include <sys/stat.h>
13 #ifndef WIN32
14 #include <sys/queue.h>
15 #include <unistd.h>
16 #endif
17 #include <time.h>
18 #ifdef HAVE_SYS_TIME_H
19 #include <sys/time.h>
20 #endif
21 #include <fcntl.h>
22 #include <stdlib.h>
23 #include <stdio.h>
24 #include <string.h>
25 #include <errno.h>
26
27 #include <event.h>
28 #include <evutil.h>
29
30 int lasttime;
31
32 static void
33 timeout_cb(int fd, short event, void *arg)
34 {
35 struct timeval tv;
36 struct event *timeout = arg;
37 int newtime = time(NULL);
38
39 printf("%s: called at %d: %d\n", __func__, newtime,
40 newtime - lasttime);
41 lasttime = newtime;
42
43 evutil_timerclear(&tv);
44 tv.tv_sec = 2;
45 event_add(timeout, &tv);
46 }
47
48 int
49 main (int argc, char **argv)
50 {
51 struct event timeout;
52 struct timeval tv;
53
54 /* Initalize the event library */
55 event_init();
56
57 /* Initalize one event */
58 evtimer_set(&timeout, timeout_cb, &timeout);
59
60 evutil_timerclear(&tv);
61 tv.tv_sec = 2;
62 event_add(&timeout, &tv);
63
64 lasttime = time(NULL);
65
66 event_dispatch();
67
68 return (0);
69 }
70
OLDNEW
« no previous file with comments | « third_party/libevent/sample/signal-test.c ('k') | third_party/libevent/select.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698