polyphony 0.13 → 0.14

Sign up to get free protection for your applications and to get access to all the features.
Files changed (135) hide show
  1. checksums.yaml +4 -4
  2. data/.gitbook.yaml +5 -0
  3. data/.gitignore +55 -0
  4. data/.rubocop.yml +49 -0
  5. data/CHANGELOG.md +13 -2
  6. data/Gemfile +3 -0
  7. data/Gemfile.lock +31 -0
  8. data/LICENSE +21 -0
  9. data/README.md +35 -18
  10. data/Rakefile +20 -0
  11. data/TODO.md +49 -0
  12. data/docs/getting-started/getting-started.md +10 -0
  13. data/docs/getting-started/tutorial.md +2 -0
  14. data/docs/summary.md +9 -0
  15. data/examples/core/cancel.rb +10 -0
  16. data/examples/core/channel_echo.rb +43 -0
  17. data/examples/core/enumerator.rb +14 -0
  18. data/examples/core/fork.rb +22 -0
  19. data/examples/core/genserver.rb +74 -0
  20. data/examples/core/lock.rb +20 -0
  21. data/examples/core/move_on.rb +11 -0
  22. data/examples/core/move_on_twice.rb +17 -0
  23. data/examples/core/move_on_with_ensure.rb +17 -0
  24. data/examples/core/multiple_async.rb +17 -0
  25. data/examples/core/nested_async.rb +18 -0
  26. data/examples/core/nested_cancel.rb +41 -0
  27. data/examples/core/nested_multiple_async.rb +19 -0
  28. data/examples/core/next_tick.rb +13 -0
  29. data/examples/core/pulse.rb +13 -0
  30. data/examples/core/resource.rb +29 -0
  31. data/examples/core/resource_cancel.rb +34 -0
  32. data/examples/core/resource_delegate.rb +32 -0
  33. data/examples/core/sleep.rb +9 -0
  34. data/examples/core/sleep2.rb +13 -0
  35. data/examples/core/spawn.rb +15 -0
  36. data/examples/core/spawn_cancel.rb +19 -0
  37. data/examples/core/spawn_error.rb +28 -0
  38. data/examples/core/supervisor.rb +22 -0
  39. data/examples/core/supervisor_with_cancel_scope.rb +24 -0
  40. data/examples/core/supervisor_with_error.rb +23 -0
  41. data/examples/core/supervisor_with_manual_move_on.rb +25 -0
  42. data/examples/core/thread.rb +30 -0
  43. data/examples/core/thread_cancel.rb +30 -0
  44. data/examples/core/thread_pool.rb +60 -0
  45. data/examples/core/throttle.rb +17 -0
  46. data/examples/fs/read.rb +37 -0
  47. data/examples/interfaces/pg_client.rb +38 -0
  48. data/examples/interfaces/pg_pool.rb +37 -0
  49. data/examples/interfaces/pg_query.rb +32 -0
  50. data/examples/interfaces/redis_channels.rb +119 -0
  51. data/examples/interfaces/redis_client.rb +21 -0
  52. data/examples/interfaces/redis_pubsub.rb +26 -0
  53. data/examples/interfaces/redis_pubsub_perf.rb +65 -0
  54. data/examples/io/config.ru +3 -0
  55. data/examples/io/echo_client.rb +22 -0
  56. data/examples/io/echo_server.rb +14 -0
  57. data/examples/io/echo_server_with_timeout.rb +33 -0
  58. data/examples/io/echo_stdin.rb +15 -0
  59. data/examples/io/happy_eyeballs.rb +32 -0
  60. data/examples/io/http_client.rb +19 -0
  61. data/examples/io/http_server.js +24 -0
  62. data/examples/io/http_server.rb +16 -0
  63. data/examples/io/http_server_forked.rb +27 -0
  64. data/examples/io/http_server_throttled.rb +16 -0
  65. data/examples/io/http_ws_server.rb +42 -0
  66. data/examples/io/https_client.rb +17 -0
  67. data/examples/io/https_server.rb +23 -0
  68. data/examples/io/https_wss_server.rb +46 -0
  69. data/examples/io/rack_server.rb +19 -0
  70. data/examples/io/rack_server_https.rb +24 -0
  71. data/examples/io/rack_server_https_forked.rb +32 -0
  72. data/examples/io/websocket_server.rb +33 -0
  73. data/examples/io/ws_page.html +34 -0
  74. data/examples/io/wss_page.html +34 -0
  75. data/examples/performance/perf_multi_snooze.rb +21 -0
  76. data/examples/performance/perf_snooze.rb +30 -0
  77. data/examples/performance/thread-vs-fiber/polyphony_server.rb +63 -0
  78. data/examples/performance/thread-vs-fiber/threaded_server.rb +27 -0
  79. data/examples/streams/lines.rb +27 -0
  80. data/examples/streams/stdio.rb +18 -0
  81. data/ext/ev/async.c +168 -0
  82. data/ext/ev/child.c +169 -0
  83. data/ext/ev/ev.h +32 -0
  84. data/ext/ev/ev_ext.c +20 -0
  85. data/ext/ev/ev_module.c +222 -0
  86. data/ext/ev/io.c +405 -0
  87. data/ext/ev/libev.h +9 -0
  88. data/ext/ev/signal.c +119 -0
  89. data/ext/ev/timer.c +197 -0
  90. data/ext/libev/Changes +513 -0
  91. data/ext/libev/LICENSE +37 -0
  92. data/ext/libev/README +58 -0
  93. data/ext/libev/README.embed +3 -0
  94. data/ext/libev/ev.c +5214 -0
  95. data/ext/libev/ev.h +849 -0
  96. data/ext/libev/ev_epoll.c +285 -0
  97. data/ext/libev/ev_kqueue.c +218 -0
  98. data/ext/libev/ev_poll.c +151 -0
  99. data/ext/libev/ev_port.c +189 -0
  100. data/ext/libev/ev_select.c +316 -0
  101. data/ext/libev/ev_vars.h +204 -0
  102. data/ext/libev/ev_win32.c +162 -0
  103. data/ext/libev/ev_wrap.h +200 -0
  104. data/ext/libev/test_libev_win32.c +123 -0
  105. data/lib/polyphony.rb +7 -2
  106. data/lib/polyphony/core.rb +1 -1
  107. data/lib/polyphony/core/{coroutine.rb → coprocess.rb} +10 -10
  108. data/lib/polyphony/core/exceptions.rb +5 -5
  109. data/lib/polyphony/core/supervisor.rb +16 -16
  110. data/lib/polyphony/core/thread.rb +1 -1
  111. data/lib/polyphony/extensions/io.rb +43 -42
  112. data/lib/polyphony/extensions/kernel.rb +10 -34
  113. data/lib/polyphony/extensions/postgres.rb +3 -2
  114. data/lib/polyphony/extensions/redis.rb +1 -1
  115. data/lib/polyphony/extensions/socket.rb +8 -4
  116. data/lib/polyphony/extensions/ssl.rb +0 -54
  117. data/lib/polyphony/http/agent.rb +4 -10
  118. data/lib/polyphony/http/http1.rb +25 -25
  119. data/lib/polyphony/http/http1_request.rb +38 -26
  120. data/lib/polyphony/http/http2.rb +4 -5
  121. data/lib/polyphony/http/http2_request.rb +12 -18
  122. data/lib/polyphony/http/rack.rb +1 -3
  123. data/lib/polyphony/http/server.rb +9 -9
  124. data/lib/polyphony/net.rb +2 -2
  125. data/lib/polyphony/resource_pool.rb +5 -1
  126. data/lib/polyphony/version.rb +1 -1
  127. data/lib/polyphony/websocket.rb +52 -0
  128. data/polyphony.gemspec +31 -0
  129. data/test/test_coprocess.rb +131 -0
  130. data/test/test_core.rb +274 -0
  131. data/test/test_ev.rb +117 -0
  132. data/test/test_io.rb +38 -0
  133. metadata +113 -7
  134. data/lib/polyphony/core/async.rb +0 -36
  135. data/lib/polyphony/net_old.rb +0 -299
@@ -0,0 +1,849 @@
1
+ /*
2
+ * libev native API header
3
+ *
4
+ * Copyright (c) 2007,2008,2009,2010,2011,2012,2015 Marc Alexander Lehmann <libev@schmorp.de>
5
+ * All rights reserved.
6
+ *
7
+ * Redistribution and use in source and binary forms, with or without modifica-
8
+ * tion, are permitted provided that the following conditions are met:
9
+ *
10
+ * 1. Redistributions of source code must retain the above copyright notice,
11
+ * this list of conditions and the following disclaimer.
12
+ *
13
+ * 2. Redistributions in binary form must reproduce the above copyright
14
+ * notice, this list of conditions and the following disclaimer in the
15
+ * documentation and/or other materials provided with the distribution.
16
+ *
17
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
18
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MER-
19
+ * CHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
20
+ * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPE-
21
+ * CIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
22
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
23
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
24
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTH-
25
+ * ERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
26
+ * OF THE POSSIBILITY OF SUCH DAMAGE.
27
+ *
28
+ * Alternatively, the contents of this file may be used under the terms of
29
+ * the GNU General Public License ("GPL") version 2 or any later version,
30
+ * in which case the provisions of the GPL are applicable instead of
31
+ * the above. If you wish to allow the use of your version of this file
32
+ * only under the terms of the GPL and not to allow others to use your
33
+ * version of this file under the BSD license, indicate your decision
34
+ * by deleting the provisions above and replace them with the notice
35
+ * and other provisions required by the GPL. If you do not delete the
36
+ * provisions above, a recipient may use your version of this file under
37
+ * either the BSD or the GPL.
38
+ */
39
+
40
+ #ifndef EV_H_
41
+ #define EV_H_
42
+
43
+ #ifdef __cplusplus
44
+ # define EV_CPP(x) x
45
+ # if __cplusplus >= 201103L
46
+ # define EV_THROW noexcept
47
+ # else
48
+ # define EV_THROW throw ()
49
+ # endif
50
+ #else
51
+ # define EV_CPP(x)
52
+ # define EV_THROW
53
+ #endif
54
+
55
+ EV_CPP(extern "C" {)
56
+
57
+ /*****************************************************************************/
58
+
59
+ #ifndef EV_FEATURES
60
+ # if defined __OPTIMIZE_SIZE__
61
+ # define EV_FEATURES 0x7c
62
+ # else
63
+ # define EV_FEATURES 0x7f
64
+ # endif
65
+ #endif
66
+
67
+ #define EV_FEATURE_CODE ((EV_FEATURES) & 1)
68
+ #define EV_FEATURE_DATA ((EV_FEATURES) & 2)
69
+ #define EV_FEATURE_CONFIG ((EV_FEATURES) & 4)
70
+ #define EV_FEATURE_API ((EV_FEATURES) & 8)
71
+ #define EV_FEATURE_WATCHERS ((EV_FEATURES) & 16)
72
+ #define EV_FEATURE_BACKENDS ((EV_FEATURES) & 32)
73
+ #define EV_FEATURE_OS ((EV_FEATURES) & 64)
74
+
75
+ /* these priorities are inclusive, higher priorities will be invoked earlier */
76
+ #ifndef EV_MINPRI
77
+ # define EV_MINPRI (EV_FEATURE_CONFIG ? -2 : 0)
78
+ #endif
79
+ #ifndef EV_MAXPRI
80
+ # define EV_MAXPRI (EV_FEATURE_CONFIG ? +2 : 0)
81
+ #endif
82
+
83
+ #ifndef EV_MULTIPLICITY
84
+ # define EV_MULTIPLICITY EV_FEATURE_CONFIG
85
+ #endif
86
+
87
+ #ifndef EV_PERIODIC_ENABLE
88
+ # define EV_PERIODIC_ENABLE EV_FEATURE_WATCHERS
89
+ #endif
90
+
91
+ #ifndef EV_STAT_ENABLE
92
+ # define EV_STAT_ENABLE EV_FEATURE_WATCHERS
93
+ #endif
94
+
95
+ #ifndef EV_PREPARE_ENABLE
96
+ # define EV_PREPARE_ENABLE EV_FEATURE_WATCHERS
97
+ #endif
98
+
99
+ #ifndef EV_CHECK_ENABLE
100
+ # define EV_CHECK_ENABLE EV_FEATURE_WATCHERS
101
+ #endif
102
+
103
+ #ifndef EV_IDLE_ENABLE
104
+ # define EV_IDLE_ENABLE EV_FEATURE_WATCHERS
105
+ #endif
106
+
107
+ #ifndef EV_FORK_ENABLE
108
+ # define EV_FORK_ENABLE EV_FEATURE_WATCHERS
109
+ #endif
110
+
111
+ #ifndef EV_CLEANUP_ENABLE
112
+ # define EV_CLEANUP_ENABLE EV_FEATURE_WATCHERS
113
+ #endif
114
+
115
+ #ifndef EV_SIGNAL_ENABLE
116
+ # define EV_SIGNAL_ENABLE EV_FEATURE_WATCHERS
117
+ #endif
118
+
119
+ #ifndef EV_CHILD_ENABLE
120
+ # ifdef _WIN32
121
+ # define EV_CHILD_ENABLE 0
122
+ # else
123
+ # define EV_CHILD_ENABLE EV_FEATURE_WATCHERS
124
+ #endif
125
+ #endif
126
+
127
+ #ifndef EV_ASYNC_ENABLE
128
+ # define EV_ASYNC_ENABLE EV_FEATURE_WATCHERS
129
+ #endif
130
+
131
+ #ifndef EV_EMBED_ENABLE
132
+ # define EV_EMBED_ENABLE EV_FEATURE_WATCHERS
133
+ #endif
134
+
135
+ #ifndef EV_WALK_ENABLE
136
+ # define EV_WALK_ENABLE 0 /* not yet */
137
+ #endif
138
+
139
+ /*****************************************************************************/
140
+
141
+ #if EV_CHILD_ENABLE && !EV_SIGNAL_ENABLE
142
+ # undef EV_SIGNAL_ENABLE
143
+ # define EV_SIGNAL_ENABLE 1
144
+ #endif
145
+
146
+ /*****************************************************************************/
147
+
148
+ typedef double ev_tstamp;
149
+
150
+ #include <string.h> /* for memmove */
151
+
152
+ #ifndef EV_ATOMIC_T
153
+ # include <signal.h>
154
+ # define EV_ATOMIC_T sig_atomic_t volatile
155
+ #endif
156
+
157
+ #if EV_STAT_ENABLE
158
+ # ifdef _WIN32
159
+ # include <time.h>
160
+ # include <sys/types.h>
161
+ # endif
162
+ # include <sys/stat.h>
163
+ #endif
164
+
165
+ /* support multiple event loops? */
166
+ #if EV_MULTIPLICITY
167
+ struct ev_loop;
168
+ # define EV_P struct ev_loop *loop /* a loop as sole parameter in a declaration */
169
+ # define EV_P_ EV_P, /* a loop as first of multiple parameters */
170
+ # define EV_A loop /* a loop as sole argument to a function call */
171
+ # define EV_A_ EV_A, /* a loop as first of multiple arguments */
172
+ # define EV_DEFAULT_UC ev_default_loop_uc_ () /* the default loop, if initialised, as sole arg */
173
+ # define EV_DEFAULT_UC_ EV_DEFAULT_UC, /* the default loop as first of multiple arguments */
174
+ # define EV_DEFAULT ev_default_loop (0) /* the default loop as sole arg */
175
+ # define EV_DEFAULT_ EV_DEFAULT, /* the default loop as first of multiple arguments */
176
+ #else
177
+ # define EV_P void
178
+ # define EV_P_
179
+ # define EV_A
180
+ # define EV_A_
181
+ # define EV_DEFAULT
182
+ # define EV_DEFAULT_
183
+ # define EV_DEFAULT_UC
184
+ # define EV_DEFAULT_UC_
185
+ # undef EV_EMBED_ENABLE
186
+ #endif
187
+
188
+ /* EV_INLINE is used for functions in header files */
189
+ #if __STDC_VERSION__ >= 199901L || __GNUC__ >= 3
190
+ # define EV_INLINE static inline
191
+ #else
192
+ # define EV_INLINE static
193
+ #endif
194
+
195
+ #ifdef EV_API_STATIC
196
+ # define EV_API_DECL static
197
+ #else
198
+ # define EV_API_DECL extern
199
+ #endif
200
+
201
+ /* EV_PROTOTYPES can be used to switch of prototype declarations */
202
+ #ifndef EV_PROTOTYPES
203
+ # define EV_PROTOTYPES 1
204
+ #endif
205
+
206
+ /*****************************************************************************/
207
+
208
+ #define EV_VERSION_MAJOR 4
209
+ #define EV_VERSION_MINOR 24
210
+
211
+ /* eventmask, revents, events... */
212
+ enum {
213
+ EV_UNDEF = (int)0xFFFFFFFF, /* guaranteed to be invalid */
214
+ EV_NONE = 0x00, /* no events */
215
+ EV_READ = 0x01, /* ev_io detected read will not block */
216
+ EV_WRITE = 0x02, /* ev_io detected write will not block */
217
+ EV__IOFDSET = 0x80, /* internal use only */
218
+ EV_IO = EV_READ, /* alias for type-detection */
219
+ EV_TIMER = 0x00000100, /* timer timed out */
220
+ #if EV_COMPAT3
221
+ EV_TIMEOUT = EV_TIMER, /* pre 4.0 API compatibility */
222
+ #endif
223
+ EV_PERIODIC = 0x00000200, /* periodic timer timed out */
224
+ EV_SIGNAL = 0x00000400, /* signal was received */
225
+ EV_CHILD = 0x00000800, /* child/pid had status change */
226
+ EV_STAT = 0x00001000, /* stat data changed */
227
+ EV_IDLE = 0x00002000, /* event loop is idling */
228
+ EV_PREPARE = 0x00004000, /* event loop about to poll */
229
+ EV_CHECK = 0x00008000, /* event loop finished poll */
230
+ EV_EMBED = 0x00010000, /* embedded event loop needs sweep */
231
+ EV_FORK = 0x00020000, /* event loop resumed in child */
232
+ EV_CLEANUP = 0x00040000, /* event loop resumed in child */
233
+ EV_ASYNC = 0x00080000, /* async intra-loop signal */
234
+ EV_CUSTOM = 0x01000000, /* for use by user code */
235
+ EV_ERROR = (int)0x80000000 /* sent when an error occurs */
236
+ };
237
+
238
+ /* can be used to add custom fields to all watchers, while losing binary compatibility */
239
+ #ifndef EV_COMMON
240
+ # define EV_COMMON void *data;
241
+ #endif
242
+
243
+ #ifndef EV_CB_DECLARE
244
+ # define EV_CB_DECLARE(type) void (*cb)(EV_P_ struct type *w, int revents);
245
+ #endif
246
+ #ifndef EV_CB_INVOKE
247
+ # define EV_CB_INVOKE(watcher,revents) (watcher)->cb (EV_A_ (watcher), (revents))
248
+ #endif
249
+
250
+ /* not official, do not use */
251
+ #define EV_CB(type,name) void name (EV_P_ struct ev_ ## type *w, int revents)
252
+
253
+ /*
254
+ * struct member types:
255
+ * private: you may look at them, but not change them,
256
+ * and they might not mean anything to you.
257
+ * ro: can be read anytime, but only changed when the watcher isn't active.
258
+ * rw: can be read and modified anytime, even when the watcher is active.
259
+ *
260
+ * some internal details that might be helpful for debugging:
261
+ *
262
+ * active is either 0, which means the watcher is not active,
263
+ * or the array index of the watcher (periodics, timers)
264
+ * or the array index + 1 (most other watchers)
265
+ * or simply 1 for watchers that aren't in some array.
266
+ * pending is either 0, in which case the watcher isn't,
267
+ * or the array index + 1 in the pendings array.
268
+ */
269
+
270
+ #if EV_MINPRI == EV_MAXPRI
271
+ # define EV_DECL_PRIORITY
272
+ #elif !defined (EV_DECL_PRIORITY)
273
+ # define EV_DECL_PRIORITY int priority;
274
+ #endif
275
+
276
+ /* shared by all watchers */
277
+ #define EV_WATCHER(type) \
278
+ int active; /* private */ \
279
+ int pending; /* private */ \
280
+ EV_DECL_PRIORITY /* private */ \
281
+ EV_COMMON /* rw */ \
282
+ EV_CB_DECLARE (type) /* private */
283
+
284
+ #define EV_WATCHER_LIST(type) \
285
+ EV_WATCHER (type) \
286
+ struct ev_watcher_list *next; /* private */
287
+
288
+ #define EV_WATCHER_TIME(type) \
289
+ EV_WATCHER (type) \
290
+ ev_tstamp at; /* private */
291
+
292
+ /* base class, nothing to see here unless you subclass */
293
+ typedef struct ev_watcher
294
+ {
295
+ EV_WATCHER (ev_watcher)
296
+ } ev_watcher;
297
+
298
+ /* base class, nothing to see here unless you subclass */
299
+ typedef struct ev_watcher_list
300
+ {
301
+ EV_WATCHER_LIST (ev_watcher_list)
302
+ } ev_watcher_list;
303
+
304
+ /* base class, nothing to see here unless you subclass */
305
+ typedef struct ev_watcher_time
306
+ {
307
+ EV_WATCHER_TIME (ev_watcher_time)
308
+ } ev_watcher_time;
309
+
310
+ /* invoked when fd is either EV_READable or EV_WRITEable */
311
+ /* revent EV_READ, EV_WRITE */
312
+ typedef struct ev_io
313
+ {
314
+ EV_WATCHER_LIST (ev_io)
315
+
316
+ int fd; /* ro */
317
+ int events; /* ro */
318
+ } ev_io;
319
+
320
+ /* invoked after a specific time, repeatable (based on monotonic clock) */
321
+ /* revent EV_TIMEOUT */
322
+ typedef struct ev_timer
323
+ {
324
+ EV_WATCHER_TIME (ev_timer)
325
+
326
+ ev_tstamp repeat; /* rw */
327
+ } ev_timer;
328
+
329
+ /* invoked at some specific time, possibly repeating at regular intervals (based on UTC) */
330
+ /* revent EV_PERIODIC */
331
+ typedef struct ev_periodic
332
+ {
333
+ EV_WATCHER_TIME (ev_periodic)
334
+
335
+ ev_tstamp offset; /* rw */
336
+ ev_tstamp interval; /* rw */
337
+ ev_tstamp (*reschedule_cb)(struct ev_periodic *w, ev_tstamp now) EV_THROW; /* rw */
338
+ } ev_periodic;
339
+
340
+ /* invoked when the given signal has been received */
341
+ /* revent EV_SIGNAL */
342
+ typedef struct ev_signal
343
+ {
344
+ EV_WATCHER_LIST (ev_signal)
345
+
346
+ int signum; /* ro */
347
+ } ev_signal;
348
+
349
+ /* invoked when sigchld is received and waitpid indicates the given pid */
350
+ /* revent EV_CHILD */
351
+ /* does not support priorities */
352
+ typedef struct ev_child
353
+ {
354
+ EV_WATCHER_LIST (ev_child)
355
+
356
+ int flags; /* private */
357
+ int pid; /* ro */
358
+ int rpid; /* rw, holds the received pid */
359
+ int rstatus; /* rw, holds the exit status, use the macros from sys/wait.h */
360
+ } ev_child;
361
+
362
+ #if EV_STAT_ENABLE
363
+ /* st_nlink = 0 means missing file or other error */
364
+ # ifdef _WIN32
365
+ typedef struct _stati64 ev_statdata;
366
+ # else
367
+ typedef struct stat ev_statdata;
368
+ # endif
369
+
370
+ /* invoked each time the stat data changes for a given path */
371
+ /* revent EV_STAT */
372
+ typedef struct ev_stat
373
+ {
374
+ EV_WATCHER_LIST (ev_stat)
375
+
376
+ ev_timer timer; /* private */
377
+ ev_tstamp interval; /* ro */
378
+ const char *path; /* ro */
379
+ ev_statdata prev; /* ro */
380
+ ev_statdata attr; /* ro */
381
+
382
+ int wd; /* wd for inotify, fd for kqueue */
383
+ } ev_stat;
384
+ #endif
385
+
386
+ #if EV_IDLE_ENABLE
387
+ /* invoked when the nothing else needs to be done, keeps the process from blocking */
388
+ /* revent EV_IDLE */
389
+ typedef struct ev_idle
390
+ {
391
+ EV_WATCHER (ev_idle)
392
+ } ev_idle;
393
+ #endif
394
+
395
+ /* invoked for each run of the mainloop, just before the blocking call */
396
+ /* you can still change events in any way you like */
397
+ /* revent EV_PREPARE */
398
+ typedef struct ev_prepare
399
+ {
400
+ EV_WATCHER (ev_prepare)
401
+ } ev_prepare;
402
+
403
+ /* invoked for each run of the mainloop, just after the blocking call */
404
+ /* revent EV_CHECK */
405
+ typedef struct ev_check
406
+ {
407
+ EV_WATCHER (ev_check)
408
+ } ev_check;
409
+
410
+ #if EV_FORK_ENABLE
411
+ /* the callback gets invoked before check in the child process when a fork was detected */
412
+ /* revent EV_FORK */
413
+ typedef struct ev_fork
414
+ {
415
+ EV_WATCHER (ev_fork)
416
+ } ev_fork;
417
+ #endif
418
+
419
+ #if EV_CLEANUP_ENABLE
420
+ /* is invoked just before the loop gets destroyed */
421
+ /* revent EV_CLEANUP */
422
+ typedef struct ev_cleanup
423
+ {
424
+ EV_WATCHER (ev_cleanup)
425
+ } ev_cleanup;
426
+ #endif
427
+
428
+ #if EV_EMBED_ENABLE
429
+ /* used to embed an event loop inside another */
430
+ /* the callback gets invoked when the event loop has handled events, and can be 0 */
431
+ typedef struct ev_embed
432
+ {
433
+ EV_WATCHER (ev_embed)
434
+
435
+ struct ev_loop *other; /* ro */
436
+ ev_io io; /* private */
437
+ ev_prepare prepare; /* private */
438
+ ev_check check; /* unused */
439
+ ev_timer timer; /* unused */
440
+ ev_periodic periodic; /* unused */
441
+ ev_idle idle; /* unused */
442
+ ev_fork fork; /* private */
443
+ #if EV_CLEANUP_ENABLE
444
+ ev_cleanup cleanup; /* unused */
445
+ #endif
446
+ } ev_embed;
447
+ #endif
448
+
449
+ #if EV_ASYNC_ENABLE
450
+ /* invoked when somebody calls ev_async_send on the watcher */
451
+ /* revent EV_ASYNC */
452
+ typedef struct ev_async
453
+ {
454
+ EV_WATCHER (ev_async)
455
+
456
+ EV_ATOMIC_T sent; /* private */
457
+ } ev_async;
458
+
459
+ # define ev_async_pending(w) (+(w)->sent)
460
+ #endif
461
+
462
+ /* the presence of this union forces similar struct layout */
463
+ union ev_any_watcher
464
+ {
465
+ struct ev_watcher w;
466
+ struct ev_watcher_list wl;
467
+
468
+ struct ev_io io;
469
+ struct ev_timer timer;
470
+ struct ev_periodic periodic;
471
+ struct ev_signal signal;
472
+ struct ev_child child;
473
+ #if EV_STAT_ENABLE
474
+ struct ev_stat stat;
475
+ #endif
476
+ #if EV_IDLE_ENABLE
477
+ struct ev_idle idle;
478
+ #endif
479
+ struct ev_prepare prepare;
480
+ struct ev_check check;
481
+ #if EV_FORK_ENABLE
482
+ struct ev_fork fork;
483
+ #endif
484
+ #if EV_CLEANUP_ENABLE
485
+ struct ev_cleanup cleanup;
486
+ #endif
487
+ #if EV_EMBED_ENABLE
488
+ struct ev_embed embed;
489
+ #endif
490
+ #if EV_ASYNC_ENABLE
491
+ struct ev_async async;
492
+ #endif
493
+ };
494
+
495
+ /* flag bits for ev_default_loop and ev_loop_new */
496
+ enum {
497
+ /* the default */
498
+ EVFLAG_AUTO = 0x00000000U, /* not quite a mask */
499
+ /* flag bits */
500
+ EVFLAG_NOENV = 0x01000000U, /* do NOT consult environment */
501
+ EVFLAG_FORKCHECK = 0x02000000U, /* check for a fork in each iteration */
502
+ /* debugging/feature disable */
503
+ EVFLAG_NOINOTIFY = 0x00100000U, /* do not attempt to use inotify */
504
+ #if EV_COMPAT3
505
+ EVFLAG_NOSIGFD = 0, /* compatibility to pre-3.9 */
506
+ #endif
507
+ EVFLAG_SIGNALFD = 0x00200000U, /* attempt to use signalfd */
508
+ EVFLAG_NOSIGMASK = 0x00400000U /* avoid modifying the signal mask */
509
+ };
510
+
511
+ /* method bits to be ored together */
512
+ enum {
513
+ EVBACKEND_SELECT = 0x00000001U, /* available just about anywhere */
514
+ EVBACKEND_POLL = 0x00000002U, /* !win, !aix, broken on osx */
515
+ EVBACKEND_EPOLL = 0x00000004U, /* linux */
516
+ EVBACKEND_KQUEUE = 0x00000008U, /* bsd, broken on osx */
517
+ EVBACKEND_DEVPOLL = 0x00000010U, /* solaris 8 */ /* NYI */
518
+ EVBACKEND_PORT = 0x00000020U, /* solaris 10 */
519
+ EVBACKEND_ALL = 0x0000003FU, /* all known backends */
520
+ EVBACKEND_MASK = 0x0000FFFFU /* all future backends */
521
+ };
522
+
523
+ #if EV_PROTOTYPES
524
+ EV_API_DECL int ev_version_major (void) EV_THROW;
525
+ EV_API_DECL int ev_version_minor (void) EV_THROW;
526
+
527
+ EV_API_DECL unsigned int ev_supported_backends (void) EV_THROW;
528
+ EV_API_DECL unsigned int ev_recommended_backends (void) EV_THROW;
529
+ EV_API_DECL unsigned int ev_embeddable_backends (void) EV_THROW;
530
+
531
+ EV_API_DECL ev_tstamp ev_time (void) EV_THROW;
532
+ EV_API_DECL void ev_sleep (ev_tstamp delay) EV_THROW; /* sleep for a while */
533
+
534
+ /* Sets the allocation function to use, works like realloc.
535
+ * It is used to allocate and free memory.
536
+ * If it returns zero when memory needs to be allocated, the library might abort
537
+ * or take some potentially destructive action.
538
+ * The default is your system realloc function.
539
+ */
540
+ EV_API_DECL void ev_set_allocator (void *(*cb)(void *ptr, long size) EV_THROW) EV_THROW;
541
+
542
+ /* set the callback function to call on a
543
+ * retryable syscall error
544
+ * (such as failed select, poll, epoll_wait)
545
+ */
546
+ EV_API_DECL void ev_set_syserr_cb (void (*cb)(const char *msg) EV_THROW) EV_THROW;
547
+
548
+ #if EV_MULTIPLICITY
549
+
550
+ /* the default loop is the only one that handles signals and child watchers */
551
+ /* you can call this as often as you like */
552
+ EV_API_DECL struct ev_loop *ev_default_loop (unsigned int flags EV_CPP (= 0)) EV_THROW;
553
+
554
+ #ifdef EV_API_STATIC
555
+ EV_API_DECL struct ev_loop *ev_default_loop_ptr;
556
+ #endif
557
+
558
+ EV_INLINE struct ev_loop *
559
+ ev_default_loop_uc_ (void) EV_THROW
560
+ {
561
+ extern struct ev_loop *ev_default_loop_ptr;
562
+
563
+ return ev_default_loop_ptr;
564
+ }
565
+
566
+ EV_INLINE int
567
+ ev_is_default_loop (EV_P) EV_THROW
568
+ {
569
+ return EV_A == EV_DEFAULT_UC;
570
+ }
571
+
572
+ /* create and destroy alternative loops that don't handle signals */
573
+ EV_API_DECL struct ev_loop *ev_loop_new (unsigned int flags EV_CPP (= 0)) EV_THROW;
574
+
575
+ EV_API_DECL ev_tstamp ev_now (EV_P) EV_THROW; /* time w.r.t. timers and the eventloop, updated after each poll */
576
+
577
+ #else
578
+
579
+ EV_API_DECL int ev_default_loop (unsigned int flags EV_CPP (= 0)) EV_THROW; /* returns true when successful */
580
+
581
+ EV_API_DECL ev_tstamp ev_rt_now;
582
+
583
+ EV_INLINE ev_tstamp
584
+ ev_now (void) EV_THROW
585
+ {
586
+ return ev_rt_now;
587
+ }
588
+
589
+ /* looks weird, but ev_is_default_loop (EV_A) still works if this exists */
590
+ EV_INLINE int
591
+ ev_is_default_loop (void) EV_THROW
592
+ {
593
+ return 1;
594
+ }
595
+
596
+ #endif /* multiplicity */
597
+
598
+ /* destroy event loops, also works for the default loop */
599
+ EV_API_DECL void ev_loop_destroy (EV_P);
600
+
601
+ /* this needs to be called after fork, to duplicate the loop */
602
+ /* when you want to re-use it in the child */
603
+ /* you can call it in either the parent or the child */
604
+ /* you can actually call it at any time, anywhere :) */
605
+ EV_API_DECL void ev_loop_fork (EV_P) EV_THROW;
606
+
607
+ EV_API_DECL unsigned int ev_backend (EV_P) EV_THROW; /* backend in use by loop */
608
+
609
+ EV_API_DECL void ev_now_update (EV_P) EV_THROW; /* update event loop time */
610
+
611
+ #if EV_WALK_ENABLE
612
+ /* walk (almost) all watchers in the loop of a given type, invoking the */
613
+ /* callback on every such watcher. The callback might stop the watcher, */
614
+ /* but do nothing else with the loop */
615
+ EV_API_DECL void ev_walk (EV_P_ int types, void (*cb)(EV_P_ int type, void *w)) EV_THROW;
616
+ #endif
617
+
618
+ #endif /* prototypes */
619
+
620
+ /* ev_run flags values */
621
+ enum {
622
+ EVRUN_NOWAIT = 1, /* do not block/wait */
623
+ EVRUN_ONCE = 2 /* block *once* only */
624
+ };
625
+
626
+ /* ev_break how values */
627
+ enum {
628
+ EVBREAK_CANCEL = 0, /* undo unloop */
629
+ EVBREAK_ONE = 1, /* unloop once */
630
+ EVBREAK_ALL = 2 /* unloop all loops */
631
+ };
632
+
633
+ #if EV_PROTOTYPES
634
+ EV_API_DECL int ev_run (EV_P_ int flags EV_CPP (= 0));
635
+ EV_API_DECL void ev_break (EV_P_ int how EV_CPP (= EVBREAK_ONE)) EV_THROW; /* break out of the loop */
636
+
637
+ /*
638
+ * ref/unref can be used to add or remove a refcount on the mainloop. every watcher
639
+ * keeps one reference. if you have a long-running watcher you never unregister that
640
+ * should not keep ev_loop from running, unref() after starting, and ref() before stopping.
641
+ */
642
+ EV_API_DECL void ev_ref (EV_P) EV_THROW;
643
+ EV_API_DECL void ev_unref (EV_P) EV_THROW;
644
+
645
+ /*
646
+ * convenience function, wait for a single event, without registering an event watcher
647
+ * if timeout is < 0, do wait indefinitely
648
+ */
649
+ EV_API_DECL void ev_once (EV_P_ int fd, int events, ev_tstamp timeout, void (*cb)(int revents, void *arg), void *arg) EV_THROW;
650
+
651
+ # if EV_FEATURE_API
652
+ EV_API_DECL unsigned int ev_iteration (EV_P) EV_THROW; /* number of loop iterations */
653
+ EV_API_DECL unsigned int ev_depth (EV_P) EV_THROW; /* #ev_loop enters - #ev_loop leaves */
654
+ EV_API_DECL void ev_verify (EV_P) EV_THROW; /* abort if loop data corrupted */
655
+
656
+ EV_API_DECL void ev_set_io_collect_interval (EV_P_ ev_tstamp interval) EV_THROW; /* sleep at least this time, default 0 */
657
+ EV_API_DECL void ev_set_timeout_collect_interval (EV_P_ ev_tstamp interval) EV_THROW; /* sleep at least this time, default 0 */
658
+
659
+ /* advanced stuff for threading etc. support, see docs */
660
+ EV_API_DECL void ev_set_userdata (EV_P_ void *data) EV_THROW;
661
+ EV_API_DECL void *ev_userdata (EV_P) EV_THROW;
662
+ typedef void (*ev_loop_callback)(EV_P);
663
+ EV_API_DECL void ev_set_invoke_pending_cb (EV_P_ ev_loop_callback invoke_pending_cb) EV_THROW;
664
+ /* C++ doesn't allow the use of the ev_loop_callback typedef here, so we need to spell it out */
665
+ EV_API_DECL void ev_set_loop_release_cb (EV_P_ void (*release)(EV_P) EV_THROW, void (*acquire)(EV_P) EV_THROW) EV_THROW;
666
+
667
+ EV_API_DECL unsigned int ev_pending_count (EV_P) EV_THROW; /* number of pending events, if any */
668
+ EV_API_DECL void ev_invoke_pending (EV_P); /* invoke all pending watchers */
669
+
670
+ /*
671
+ * stop/start the timer handling.
672
+ */
673
+ EV_API_DECL void ev_suspend (EV_P) EV_THROW;
674
+ EV_API_DECL void ev_resume (EV_P) EV_THROW;
675
+ #endif
676
+
677
+ #endif
678
+
679
+ /* these may evaluate ev multiple times, and the other arguments at most once */
680
+ /* either use ev_init + ev_TYPE_set, or the ev_TYPE_init macro, below, to first initialise a watcher */
681
+ #define ev_init(ev,cb_) do { \
682
+ ((ev_watcher *)(void *)(ev))->active = \
683
+ ((ev_watcher *)(void *)(ev))->pending = 0; \
684
+ ev_set_priority ((ev), 0); \
685
+ ev_set_cb ((ev), cb_); \
686
+ } while (0)
687
+
688
+ #define ev_io_set(ev,fd_,events_) do { (ev)->fd = (fd_); (ev)->events = (events_) | EV__IOFDSET; } while (0)
689
+ #define ev_timer_set(ev,after_,repeat_) do { ((ev_watcher_time *)(ev))->at = (after_); (ev)->repeat = (repeat_); } while (0)
690
+ #define ev_periodic_set(ev,ofs_,ival_,rcb_) do { (ev)->offset = (ofs_); (ev)->interval = (ival_); (ev)->reschedule_cb = (rcb_); } while (0)
691
+ #define ev_signal_set(ev,signum_) do { (ev)->signum = (signum_); } while (0)
692
+ #define ev_child_set(ev,pid_,trace_) do { (ev)->pid = (pid_); (ev)->flags = !!(trace_); } while (0)
693
+ #define ev_stat_set(ev,path_,interval_) do { (ev)->path = (path_); (ev)->interval = (interval_); (ev)->wd = -2; } while (0)
694
+ #define ev_idle_set(ev) /* nop, yes, this is a serious in-joke */
695
+ #define ev_prepare_set(ev) /* nop, yes, this is a serious in-joke */
696
+ #define ev_check_set(ev) /* nop, yes, this is a serious in-joke */
697
+ #define ev_embed_set(ev,other_) do { (ev)->other = (other_); } while (0)
698
+ #define ev_fork_set(ev) /* nop, yes, this is a serious in-joke */
699
+ #define ev_cleanup_set(ev) /* nop, yes, this is a serious in-joke */
700
+ #define ev_async_set(ev) /* nop, yes, this is a serious in-joke */
701
+
702
+ #define ev_io_init(ev,cb,fd,events) do { ev_init ((ev), (cb)); ev_io_set ((ev),(fd),(events)); } while (0)
703
+ #define ev_timer_init(ev,cb,after,repeat) do { ev_init ((ev), (cb)); ev_timer_set ((ev),(after),(repeat)); } while (0)
704
+ #define ev_periodic_init(ev,cb,ofs,ival,rcb) do { ev_init ((ev), (cb)); ev_periodic_set ((ev),(ofs),(ival),(rcb)); } while (0)
705
+ #define ev_signal_init(ev,cb,signum) do { ev_init ((ev), (cb)); ev_signal_set ((ev), (signum)); } while (0)
706
+ #define ev_child_init(ev,cb,pid,trace) do { ev_init ((ev), (cb)); ev_child_set ((ev),(pid),(trace)); } while (0)
707
+ #define ev_stat_init(ev,cb,path,interval) do { ev_init ((ev), (cb)); ev_stat_set ((ev),(path),(interval)); } while (0)
708
+ #define ev_idle_init(ev,cb) do { ev_init ((ev), (cb)); ev_idle_set ((ev)); } while (0)
709
+ #define ev_prepare_init(ev,cb) do { ev_init ((ev), (cb)); ev_prepare_set ((ev)); } while (0)
710
+ #define ev_check_init(ev,cb) do { ev_init ((ev), (cb)); ev_check_set ((ev)); } while (0)
711
+ #define ev_embed_init(ev,cb,other) do { ev_init ((ev), (cb)); ev_embed_set ((ev),(other)); } while (0)
712
+ #define ev_fork_init(ev,cb) do { ev_init ((ev), (cb)); ev_fork_set ((ev)); } while (0)
713
+ #define ev_cleanup_init(ev,cb) do { ev_init ((ev), (cb)); ev_cleanup_set ((ev)); } while (0)
714
+ #define ev_async_init(ev,cb) do { ev_init ((ev), (cb)); ev_async_set ((ev)); } while (0)
715
+
716
+ #define ev_is_pending(ev) (0 + ((ev_watcher *)(void *)(ev))->pending) /* ro, true when watcher is waiting for callback invocation */
717
+ #define ev_is_active(ev) (0 + ((ev_watcher *)(void *)(ev))->active) /* ro, true when the watcher has been started */
718
+
719
+ #define ev_cb_(ev) (ev)->cb /* rw */
720
+ #define ev_cb(ev) (memmove (&ev_cb_ (ev), &((ev_watcher *)(ev))->cb, sizeof (ev_cb_ (ev))), (ev)->cb)
721
+
722
+ #if EV_MINPRI == EV_MAXPRI
723
+ # define ev_priority(ev) ((ev), EV_MINPRI)
724
+ # define ev_set_priority(ev,pri) ((ev), (pri))
725
+ #else
726
+ # define ev_priority(ev) (+(((ev_watcher *)(void *)(ev))->priority))
727
+ # define ev_set_priority(ev,pri) ( (ev_watcher *)(void *)(ev))->priority = (pri)
728
+ #endif
729
+
730
+ #define ev_periodic_at(ev) (+((ev_watcher_time *)(ev))->at)
731
+
732
+ #ifndef ev_set_cb
733
+ # define ev_set_cb(ev,cb_) (ev_cb_ (ev) = (cb_), memmove (&((ev_watcher *)(ev))->cb, &ev_cb_ (ev), sizeof (ev_cb_ (ev))))
734
+ #endif
735
+
736
+ /* stopping (enabling, adding) a watcher does nothing if it is already running */
737
+ /* stopping (disabling, deleting) a watcher does nothing unless it's already running */
738
+ #if EV_PROTOTYPES
739
+
740
+ /* feeds an event into a watcher as if the event actually occurred */
741
+ /* accepts any ev_watcher type */
742
+ EV_API_DECL void ev_feed_event (EV_P_ void *w, int revents) EV_THROW;
743
+ EV_API_DECL void ev_feed_fd_event (EV_P_ int fd, int revents) EV_THROW;
744
+ #if EV_SIGNAL_ENABLE
745
+ EV_API_DECL void ev_feed_signal (int signum) EV_THROW;
746
+ EV_API_DECL void ev_feed_signal_event (EV_P_ int signum) EV_THROW;
747
+ #endif
748
+ EV_API_DECL void ev_invoke (EV_P_ void *w, int revents);
749
+ EV_API_DECL int ev_clear_pending (EV_P_ void *w) EV_THROW;
750
+
751
+ EV_API_DECL void ev_io_start (EV_P_ ev_io *w) EV_THROW;
752
+ EV_API_DECL void ev_io_stop (EV_P_ ev_io *w) EV_THROW;
753
+
754
+ EV_API_DECL void ev_timer_start (EV_P_ ev_timer *w) EV_THROW;
755
+ EV_API_DECL void ev_timer_stop (EV_P_ ev_timer *w) EV_THROW;
756
+ /* stops if active and no repeat, restarts if active and repeating, starts if inactive and repeating */
757
+ EV_API_DECL void ev_timer_again (EV_P_ ev_timer *w) EV_THROW;
758
+ /* return remaining time */
759
+ EV_API_DECL ev_tstamp ev_timer_remaining (EV_P_ ev_timer *w) EV_THROW;
760
+
761
+ #if EV_PERIODIC_ENABLE
762
+ EV_API_DECL void ev_periodic_start (EV_P_ ev_periodic *w) EV_THROW;
763
+ EV_API_DECL void ev_periodic_stop (EV_P_ ev_periodic *w) EV_THROW;
764
+ EV_API_DECL void ev_periodic_again (EV_P_ ev_periodic *w) EV_THROW;
765
+ #endif
766
+
767
+ /* only supported in the default loop */
768
+ #if EV_SIGNAL_ENABLE
769
+ EV_API_DECL void ev_signal_start (EV_P_ ev_signal *w) EV_THROW;
770
+ EV_API_DECL void ev_signal_stop (EV_P_ ev_signal *w) EV_THROW;
771
+ #endif
772
+
773
+ /* only supported in the default loop */
774
+ # if EV_CHILD_ENABLE
775
+ EV_API_DECL void ev_child_start (EV_P_ ev_child *w) EV_THROW;
776
+ EV_API_DECL void ev_child_stop (EV_P_ ev_child *w) EV_THROW;
777
+ # endif
778
+
779
+ # if EV_STAT_ENABLE
780
+ EV_API_DECL void ev_stat_start (EV_P_ ev_stat *w) EV_THROW;
781
+ EV_API_DECL void ev_stat_stop (EV_P_ ev_stat *w) EV_THROW;
782
+ EV_API_DECL void ev_stat_stat (EV_P_ ev_stat *w) EV_THROW;
783
+ # endif
784
+
785
+ # if EV_IDLE_ENABLE
786
+ EV_API_DECL void ev_idle_start (EV_P_ ev_idle *w) EV_THROW;
787
+ EV_API_DECL void ev_idle_stop (EV_P_ ev_idle *w) EV_THROW;
788
+ # endif
789
+
790
+ #if EV_PREPARE_ENABLE
791
+ EV_API_DECL void ev_prepare_start (EV_P_ ev_prepare *w) EV_THROW;
792
+ EV_API_DECL void ev_prepare_stop (EV_P_ ev_prepare *w) EV_THROW;
793
+ #endif
794
+
795
+ #if EV_CHECK_ENABLE
796
+ EV_API_DECL void ev_check_start (EV_P_ ev_check *w) EV_THROW;
797
+ EV_API_DECL void ev_check_stop (EV_P_ ev_check *w) EV_THROW;
798
+ #endif
799
+
800
+ # if EV_FORK_ENABLE
801
+ EV_API_DECL void ev_fork_start (EV_P_ ev_fork *w) EV_THROW;
802
+ EV_API_DECL void ev_fork_stop (EV_P_ ev_fork *w) EV_THROW;
803
+ # endif
804
+
805
+ # if EV_CLEANUP_ENABLE
806
+ EV_API_DECL void ev_cleanup_start (EV_P_ ev_cleanup *w) EV_THROW;
807
+ EV_API_DECL void ev_cleanup_stop (EV_P_ ev_cleanup *w) EV_THROW;
808
+ # endif
809
+
810
+ # if EV_EMBED_ENABLE
811
+ /* only supported when loop to be embedded is in fact embeddable */
812
+ EV_API_DECL void ev_embed_start (EV_P_ ev_embed *w) EV_THROW;
813
+ EV_API_DECL void ev_embed_stop (EV_P_ ev_embed *w) EV_THROW;
814
+ EV_API_DECL void ev_embed_sweep (EV_P_ ev_embed *w) EV_THROW;
815
+ # endif
816
+
817
+ # if EV_ASYNC_ENABLE
818
+ EV_API_DECL void ev_async_start (EV_P_ ev_async *w) EV_THROW;
819
+ EV_API_DECL void ev_async_stop (EV_P_ ev_async *w) EV_THROW;
820
+ EV_API_DECL void ev_async_send (EV_P_ ev_async *w) EV_THROW;
821
+ # endif
822
+
823
+ #if EV_COMPAT3
824
+ #define EVLOOP_NONBLOCK EVRUN_NOWAIT
825
+ #define EVLOOP_ONESHOT EVRUN_ONCE
826
+ #define EVUNLOOP_CANCEL EVBREAK_CANCEL
827
+ #define EVUNLOOP_ONE EVBREAK_ONE
828
+ #define EVUNLOOP_ALL EVBREAK_ALL
829
+ #if EV_PROTOTYPES
830
+ EV_INLINE void ev_loop (EV_P_ int flags) { ev_run (EV_A_ flags); }
831
+ EV_INLINE void ev_unloop (EV_P_ int how ) { ev_break (EV_A_ how ); }
832
+ EV_INLINE void ev_default_destroy (void) { ev_loop_destroy (EV_DEFAULT); }
833
+ EV_INLINE void ev_default_fork (void) { ev_loop_fork (EV_DEFAULT); }
834
+ #if EV_FEATURE_API
835
+ EV_INLINE unsigned int ev_loop_count (EV_P) { return ev_iteration (EV_A); }
836
+ EV_INLINE unsigned int ev_loop_depth (EV_P) { return ev_depth (EV_A); }
837
+ EV_INLINE void ev_loop_verify (EV_P) { ev_verify (EV_A); }
838
+ #endif
839
+ #endif
840
+ #else
841
+ typedef struct ev_loop ev_loop;
842
+ #endif
843
+
844
+ #endif
845
+
846
+ EV_CPP(})
847
+
848
+ #endif
849
+