-
Notifications
You must be signed in to change notification settings - Fork 38
/
libev.patch
74 lines (70 loc) · 1.49 KB
/
libev.patch
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
diff -u A/ev.c B/ev.c
--- A/ev.c 2010-09-17 19:34:16.000000000 +0100
+++ B/ev.c 2010-09-27 23:19:38.000000000 +0100
@@ -2226,6 +2226,13 @@
}
}
+ev_tstamp next_waittime = 0.;
+
+ev_tstamp
+ev_next_waittime() {
+ return next_waittime;
+}
+
void
ev_loop (EV_P_ int flags)
{
@@ -2370,6 +2377,25 @@
#if EV_MINIMAL < 2
--loop_depth;
#endif
+
+ // Compute the next waiting time.
+ ev_tstamp waittime = MAX_BLOCKTIME;
+
+ if (timercnt)
+ {
+ ev_tstamp to = ANHE_at (timers [HEAP0]) - mn_now + backend_fudge;
+ if (waittime > to) waittime = to;
+ }
+
+#if EV_PERIODIC_ENABLE
+ if (periodiccnt)
+ {
+ ev_tstamp to = ANHE_at (periodics [HEAP0]) - ev_rt_now + backend_fudge;
+ if (waittime > to) waittime = to;
+ }
+#endif
+
+ next_waittime = waittime;
}
void
@@ -2378,6 +2404,16 @@
loop_done = how;
}
+int ev_backend_fd()
+{
+ return backend_fd;
+}
+
+int ev_backend_changecount()
+{
+ return kqueue_changecnt;
+}
+
void
ev_ref (EV_P)
{
diff -u A/ev.h B/ev.h
--- A/ev.h 2010-09-17 19:34:16.000000000 +0100
+++ B/ev.h 2010-09-27 23:19:46.000000000 +0100
@@ -530,6 +530,10 @@
void ev_loop (EV_P_ int flags);
void ev_unloop (EV_P_ int how); /* set to 1 to break out of event loop, set to 2 to break out of all event loops */
+int ev_backend_fd();
+int ev_backend_changecount();
+ev_tstamp ev_next_waittime();
+
/*
* ref/unref can be used to add or remove a refcount on the mainloop. every watcher
* keeps one reference. if you have a long-running watcher you never unregister that