ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/include/cfperl.h
Revision: 1.109
Committed: Tue Nov 3 23:44:20 2009 UTC (14 years, 7 months ago) by root
Content type: text/plain
Branch: MAIN
Changes since 1.108: +1 -3 lines
Log Message:
tighten copyright statements for files containing no gpl code whatsoever anymore

File Contents

# User Rev Content
1 root 1.74 /*
2 root 1.90 * This file is part of Deliantra, the Roguelike Realtime MMORPG.
3 root 1.74 *
4 root 1.109 * Copyright (©) 2005,2006,2007,2008,2009 Marc Alexander Lehmann / Robin Redeker / the Deliantra team
5 root 1.74 *
6 root 1.108 * Deliantra is free software: you can redistribute it and/or modify it under
7     * the terms of the Affero GNU General Public License as published by the
8     * Free Software Foundation, either version 3 of the License, or (at your
9     * option) any later version.
10 root 1.74 *
11 root 1.81 * This program is distributed in the hope that it will be useful,
12     * but WITHOUT ANY WARRANTY; without even the implied warranty of
13     * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14     * GNU General Public License for more details.
15 root 1.74 *
16 root 1.108 * You should have received a copy of the Affero GNU General Public License
17     * and the GNU General Public License along with this program. If not, see
18     * <http://www.gnu.org/licenses/>.
19 root 1.74 *
20 root 1.90 * The authors can be reached via e-mail to <support@deliantra.net>
21 root 1.74 */
22    
23 root 1.1 //
24     // cfperl.h perl interface
25     //
26 root 1.2 #ifndef CFPERL_H__
27     #define CFPERL_H__
28    
29 root 1.64 #include <cstdarg>
30 root 1.16 #include <cstdio>
31 root 1.64 #include <bitset>
32 root 1.16
33     using namespace std;
34    
35     #include <EXTERN.h>
36     #include <perl.h>
37 root 1.20 #include <XSUB.h>
38 root 1.16
39 root 1.91 #include <EVAPI.h>
40 root 1.42 #include <CoroAPI.h>
41 root 1.36
42 root 1.42 #include "util.h"
43     #include "keyword.h"
44     #include "dynbuf.h"
45 root 1.36 #include "callback.h"
46    
47 root 1.42 //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
48    
49 root 1.16 // optimisations/workaround for functions requiring my_perl in scope (anti-bloat)
50     #undef localtime
51     #undef srand48
52     #undef drand48
53     #undef srandom
54 root 1.98 #undef opendir
55 root 1.16 #undef readdir
56 root 1.98 #undef closedir
57 root 1.16 #undef getprotobyname
58     #undef gethostbyname
59     #undef ctime
60     #undef strerror
61 root 1.87 #undef _
62 root 1.16
63 root 1.39 // same here, massive symbol spamming
64     #undef do_open
65     #undef do_close
66 root 1.42 #undef ref
67 root 1.44 #undef seed
68 root 1.39
69 root 1.16 // perl bug #40256: perl does overwrite those with reentrant versions
70     // but does not initialise their state structures.
71     #undef random
72     #undef crypt
73    
74 root 1.42 //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
75    
76 root 1.87 #define _(msg) (msg)
77     #define N_(msg) (msg)
78    
79     //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
80    
81 root 1.42 // some macros to simplify perl in-calls
82    
83     #define CHECK_ERROR \
84     if (SvTRUE (ERRSV)) \
85 root 1.95 LOG (llevError, "runtime error in %s: %s", __func__, SvPVutf8_nolen (ERRSV));
86 root 1.42
87 root 1.107 inline int call_pvsv (const char *ob, I32 flags) { return call_pv (ob, flags); }
88     inline int call_pvsv (SV *ob, I32 flags) { return call_sv (ob, flags); }
89    
90 root 1.42 #define CALL_BEGIN(args) dSP; ENTER; SAVETMPS; PUSHMARK (SP); EXTEND (SP, args)
91     #define CALL_ARG_SV(sv) PUSHs (sv_2mortal (sv)) // separate because no refcount inc
92     #define CALL_ARG(expr) PUSHs (sv_2mortal (to_sv (expr)))
93 root 1.107 #define CALL_CALL(name, flags) PUTBACK; int count = call_pvsv (name, (flags) | G_EVAL); SPAGAIN;
94 root 1.101 #define CALL_END PUTBACK; CHECK_ERROR; FREETMPS; LEAVE
95 root 1.42
96     //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
97    
98 root 1.7 void cfperl_init ();
99     void cfperl_main ();
100 root 1.94 void cfperl_tick ();
101 root 1.50 void cfperl_emergency_save ();
102 root 1.55 void cfperl_cleanup (int make_core);
103 root 1.65 void cfperl_make_book (object *book, int level);
104 root 1.80 void cfperl_send_msg (client *ns, int color, const char *type, const char *msg);
105 root 1.84 int cfperl_can_merge (object *ob1, object *ob2);
106 root 1.105 void cfperl_mapscript_activate (object *ob, int state, object *activator, object *originator = 0);
107 root 1.7
108 root 1.106 bool is_match_expr (const char *expr);
109     /* applies the match expression and returns true if it matches */
110     bool match (const char *expr, object *ob, object *self = 0, object *source = 0, object *originator = 0);
111    
112 root 1.42 //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
113    
114 root 1.95 #if IVSIZE >= 8
115     typedef IV val64;
116     typedef IV uval64;
117     # define newSVval64 newSViv
118     # define SvVAL64 SvIV
119     # define newSVuval64 newSVuv
120     # define SvUVAL64 SvUV
121     #else
122     typedef double val64;
123 root 1.96 typedef double uval64;
124 root 1.95 # define newSVval64 newSVnv
125     # define SvVAL64 SvNV
126     # define newSVuval64 newSVnv
127     # define SvUVAL64 SvNV
128     #endif
129    
130 root 1.79 extern tstamp runtime; // virtual server time, excluding time jumps and lag
131     extern tstamp NOW; // real time of current server tick
132 root 1.42
133 root 1.6 enum event_klass
134     {
135 root 1.11 KLASS_NONE,
136 root 1.3 KLASS_GLOBAL,
137 root 1.41 KLASS_ATTACHABLE,
138 root 1.40 KLASS_CLIENT,
139 root 1.3 KLASS_PLAYER,
140     KLASS_OBJECT,
141     KLASS_MAP,
142 root 1.33 KLASS_COMMAND,
143 root 1.3 };
144    
145 root 1.6 enum event_type
146     {
147 root 1.7 # define def(klass,name) EVENT_ ## klass ## _ ## name,
148 root 1.2 # include "eventinc.h"
149     # undef def
150 root 1.4 NUM_EVENT_TYPES
151 root 1.2 };
152    
153 root 1.64 // in which global events or per-type events are we interested
154     extern bitset<NUM_EVENT_TYPES> ev_want_event;
155     extern bitset<NUM_TYPES> ev_want_type;
156    
157 root 1.41 #define ARG_AV(o) DT_AV , static_cast<AV *> (o)
158     #define ARG_INT(v) DT_INT , static_cast<int> (v)
159     #define ARG_INT64(v) DT_INT64 , static_cast<sint64> (v)
160     #define ARG_DOUBLE(v) DT_DOUBLE, static_cast<double> (v)
161     #define ARG_STRING(v) DT_STRING, static_cast<const char *> (v)
162     #define ARG_DATA(s,l) DT_DATA , static_cast<const void *> (s), int (l)
163     #define ARG_OBJECT(o) DT_OBJECT, (void *)(static_cast<object *> (o))
164     #define ARG_MAP(o) DT_MAP , (void *)(static_cast<maptile *> (o))
165     #define ARG_PLAYER(o) DT_PLAYER, (void *)(static_cast<player *> (o))
166     #define ARG_ARCH(o) DT_ARCH , (void *)(static_cast<archetype *> (o))
167     #define ARG_CLIENT(o) DT_CLIENT, (void *)(static_cast<client *> (o))
168     #define ARG_PARTY(o) DT_PARTY , (void *)(static_cast<party *> (o))
169     #define ARG_REGION(o) DT_REGION, (void *)(static_cast<region *> (o))
170 root 1.3
171     // the ", ## __VA_ARGS" is, unfortunately, a gnu-cpp extension
172 root 1.66 #define INVOKE(obj,event, ...) (expect_false ((obj)->should_invoke (event)) ? (obj)->invoke (event, ## __VA_ARGS__, DT_END) : 0)
173     #define INVOKE_GLOBAL(event, ...) INVOKE (&gbl_ev, EVENT_ ## GLOBAL ## _ ## event, ## __VA_ARGS__)
174     #define INVOKE_ATTACHABLE(event, obj, ...) INVOKE (obj , EVENT_ ## ATTACHABLE ## _ ## event, ## __VA_ARGS__)
175     #define INVOKE_OBJECT(event, obj, ...) INVOKE (obj , EVENT_ ## OBJECT ## _ ## event, ## __VA_ARGS__)
176     #define INVOKE_CLIENT(event, obj, ...) INVOKE (obj , EVENT_ ## CLIENT ## _ ## event, ## __VA_ARGS__)
177     #define INVOKE_PLAYER(event, obj, ...) INVOKE (obj , EVENT_ ## PLAYER ## _ ## event, ## __VA_ARGS__)
178     #define INVOKE_MAP(event, obj, ...) INVOKE (obj , EVENT_ ## MAP ## _ ## event, ## __VA_ARGS__)
179 root 1.3
180 root 1.7 //TODO should index into @result
181     #define RESULT(idx,type) cfperl_result_ ## type (idx)
182 root 1.33 #define RESULT_DOUBLE(idx) RESULT(idx, DOUBLE)
183     #define RESULT_INT(idx) RESULT(idx, INT)
184 root 1.7
185 root 1.34 double cfperl_result_DOUBLE (int idx);
186     int cfperl_result_INT (int idx);
187 root 1.7
188 root 1.42 //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
189    
190 root 1.47 INTERFACE_CLASS (attachable)
191 root 1.86 struct attachable : refcnt_base
192 root 1.6 {
193 root 1.42 static MGVTBL vtbl;
194    
195 root 1.41 enum {
196 root 1.54 F_DESTROYED = 0x01,
197     F_DEBUG_TRACE = 0x02,
198 root 1.41 };
199 root 1.100 uint8 ACC (RW, flags);
200    
201     static unordered_vector<attachable *> mortals;
202     MTH static void check_mortals ();
203 root 1.41
204     // object is delete'd after the refcount reaches 0
205 root 1.49 MTH int refcnt_cnt () const;
206 root 1.41 // check wether the object has died and destroy
207 root 1.75 MTH void refcnt_chk () { if (expect_false (refcnt <= 0)) do_check (); }
208 root 1.41
209     // destroy the object unless it was already destroyed
210     // this politely asks everybody interested the reduce
211     // the refcount to 0 as soon as possible.
212 root 1.47 MTH void destroy ();
213 root 1.41
214     // return wether an object was destroyed already
215 root 1.47 MTH bool destroyed () const { return flags & F_DESTROYED; }
216 root 1.41
217     virtual void gather_callbacks (AV *&callbacks, event_type event) const;
218    
219     #if 0
220     private:
221     static refcounted *rc_first;
222     refcounted *rc_next;
223     #endif
224    
225     HV *self; // CF+ perl self
226 root 1.35 AV *cb; // CF+ callbacks
227 root 1.21 shstr attach; // generic extension attachment information
228 root 1.6
229 root 1.52 void sever_self (); // sever this object from its self, if it has one.
230     void optimise (); // possibly save some memory by destroying unneeded data
231 root 1.8
232 root 1.41 attachable ()
233 root 1.86 : flags (0), self (0), cb (0), attach (0)
234 root 1.8 {
235     }
236 root 1.22
237 root 1.41 attachable (const attachable &src)
238 root 1.86 : flags (0), self (0), cb (0), attach (src.attach)
239 root 1.22 {
240     }
241    
242 root 1.82 // set a custom key to the given value, or delete it if value = 0
243 root 1.88 void set_key (const char *key, const char *value = 0, bool is_utf8 = 0);
244    
245     void set_key_text (const char *key, const char *value = 0)
246     {
247     set_key (key, value, 1);
248     }
249    
250     void set_key_data (const char *key, const char *value = 0)
251     {
252     set_key (key, value, 0);
253     }
254 root 1.82
255 root 1.41 attachable &operator =(const attachable &src);
256    
257 root 1.66 // used to _quickly_ device wether to shortcut the evaluation
258     bool should_invoke (event_type event)
259 root 1.64 {
260 root 1.66 return ev_want_event [event] || cb;
261 root 1.64 }
262    
263 root 1.66 bool invoke (event_type event, ...);
264    
265 root 1.48 MTH void instantiate ();
266 root 1.41 void reattach ();
267 root 1.24
268 root 1.41 protected:
269     // do the real refcount checking work
270     void do_check ();
271 root 1.25
272 root 1.41 // the method that does the real destroy work
273     virtual void do_destroy ();
274 root 1.83
275     // destructor is protected, should not be called by anybody
276     virtual ~attachable ();
277 root 1.6 };
278    
279 root 1.41 // the global object is a pseudo object that cares for the global events
280     struct global : attachable
281 root 1.6 {
282 root 1.41 void gather_callbacks (AV *&callbacks, event_type event) const;
283 root 1.6 };
284    
285 root 1.41 extern struct global gbl_ev;
286    
287 root 1.42 //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
288    
289 root 1.89 INTERFACE_CLASS(object_freezer)
290 root 1.63 struct object_freezer : dynbuf_text
291 root 1.7 {
292 root 1.17 AV *av;
293 root 1.12
294 root 1.17 object_freezer ();
295 root 1.8 ~object_freezer ();
296    
297 root 1.41 void put (attachable *ext);
298 root 1.15
299 root 1.29 // used only for user-defined key-value pairs
300 root 1.102 void put (shstr_tmp k, shstr_tmp v)
301 root 1.20 {
302     add (k);
303    
304 root 1.66 if (expect_true (v))
305 root 1.22 add (' '), add (v);
306 root 1.20
307     add ('\n');
308     }
309    
310 root 1.29 template<typename T>
311 root 1.78 void put_kw_string (keyword k, const T &v)
312 root 1.20 {
313     int klen = keyword_len [k];
314 root 1.22 int vlen = v ? strlen (v) + 1 : 0;
315    
316     char *p = (char *)alloc (klen + vlen + 1);
317    
318     memcpy (p, keyword_str [k], klen); p += klen;
319    
320 root 1.66 if (expect_true (v))
321 root 1.22 {
322 root 1.29 *p++ = ' '; vlen--;
323 root 1.22 memcpy (p, v, vlen); p += vlen;
324     }
325    
326     *p = '\n';
327     }
328    
329 root 1.45 void put (keyword k, const char *v = 0)
330 root 1.29 {
331 root 1.78 put_kw_string (k, v);
332 root 1.29 }
333    
334 root 1.102 void put (keyword k, shstr_tmp v)
335 root 1.22 {
336 root 1.78 put_kw_string (k, v);
337 root 1.20 }
338 root 1.19
339 root 1.20 void put (keyword k, double v)
340     {
341 root 1.69 force (MAX_KEYWORD_LEN + 2 + 32);
342     fadd (keyword_str [k], keyword_len [k]);
343     fadd (' ');
344     falloc (sprintf (ptr, "%.7g", v));
345     fadd ('\n');
346 root 1.20 }
347    
348     void put_(keyword k, sint64 v)
349     {
350 root 1.69 force (MAX_KEYWORD_LEN + 2 + sint64_digits);
351     fadd (keyword_str [k], keyword_len [k]);
352     fadd (' ');
353 root 1.20 add (v);
354 root 1.69 fadd ('\n');
355 root 1.20 }
356    
357     void put_(keyword k, sint32 v)
358     {
359 root 1.69 force (MAX_KEYWORD_LEN + 2 + sint32_digits);
360     fadd (keyword_str [k], keyword_len [k]);
361     fadd (' ');
362 root 1.20 add (v);
363 root 1.69 fadd ('\n');
364 root 1.20 }
365    
366 root 1.72 void put (keyword k, float v) { put (k, (double)v); }
367     void put (keyword k, signed char v) { put_(k, (sint32)v); }
368     void put (keyword k, unsigned char v) { put_(k, (sint32)v); }
369     void put (keyword k, signed short v) { put_(k, (sint32)v); }
370     void put (keyword k, unsigned short v) { put_(k, (sint32)v); }
371     void put (keyword k, signed int v) { put_(k, (sint32)v); }
372     void put (keyword k, unsigned int v) { put_(k, (sint64)v); }
373     void put (keyword k, signed long v) { put_(k, (sint64)v); }
374     void put (keyword k, unsigned long v) { put_(k, (sint64)v); }
375     void put (keyword k, signed long long v) { put_(k, (sint64)v); }
376     void put (keyword k, unsigned long long v) { put_(k, (sint64)v); }
377    
378 root 1.102 void put (keyword kbeg, keyword kend, shstr_tmp v)
379 root 1.20 {
380 root 1.69 force (MAX_KEYWORD_LEN + 1);
381     fadd (keyword_str [kbeg], keyword_len [kbeg]); fadd ('\n');
382 root 1.20
383 root 1.66 if (expect_true (v))
384 root 1.20 {
385     add (v);
386     add ('\n');
387     }
388    
389 root 1.69 force (MAX_KEYWORD_LEN + 1);
390     fadd (keyword_str [kend], keyword_len [kend]); fadd ('\n');
391 root 1.20 }
392    
393 root 1.78 void put (keyword k, archetype *v);
394     void put (keyword k, treasurelist *v);
395     void put (keyword k, faceinfo *v);
396 root 1.18
397 root 1.32 template<typename T>
398     void put (keyword k, const refptr<T> &v)
399     {
400     put (k, (T *)v);
401     }
402    
403 root 1.89 MTH bool save (const_octet_string path);
404 root 1.31 char *as_string (); // like strdup
405 root 1.17
406 root 1.16 operator bool () { return !!av; }
407 root 1.7 };
408    
409 root 1.89 INTERFACE_CLASS(object_thawer)
410 root 1.17 struct object_thawer
411 root 1.7 {
412 root 1.66 char *line; // current beginning of line
413 root 1.21 SV *text; // text part
414     AV *av; // perl part
415 root 1.53 int linenum;
416 root 1.56 keyword kw;
417 root 1.66 char *kw_str; // the keyword parsed, as string
418     char *value; // the value, or 0 if no value
419 root 1.93 const char *value_nn; // the value, or the empty string if no value
420 root 1.47 const char *name;
421 root 1.21
422 root 1.89 operator bool () const { return !!text; }
423 root 1.16
424 root 1.47 object_thawer (const char *path = 0);
425 root 1.30 object_thawer (const char *data, AV *perlav);
426 root 1.8 ~object_thawer ();
427    
428 root 1.41 void get (attachable *obj, int oid);
429 root 1.15
430 root 1.56 // parse next line
431 root 1.89 MTH void next ();
432 root 1.57 // skip the current key-value (usually fetch next line, for
433 root 1.73 // multiline-fields, skips till the corresponding end-kw
434 root 1.89 MTH void skip ();
435     MTH void skip_block (); // skips till and over KW_end
436 root 1.57
437     char *get_str () { return value; } // may be 0
438 root 1.66 void get_ml (keyword kend, shstr &sh);
439 root 1.17
440 root 1.56 void get_ornull (shstr &sh) const { sh = value; }
441 root 1.66 void get (shstr &sh) const { sh = value; } // might want to check for non-null here
442 root 1.21
443 root 1.66 bool get_bool () const { return *value_nn == '1'; }
444 root 1.21 sint32 get_sint32 () const;
445 root 1.71 sint64 get_sint64 () const { return strtoll (value_nn, 0, 10); }
446     double get_double () const { return strtod (value_nn, 0); }
447 root 1.21
448 root 1.42 void get (float &v) { v = get_double (); }
449 root 1.21 void get (double &v) { v = get_double (); }
450    
451 root 1.66 void get (bool &i) { i = get_bool (); }
452 root 1.21 void get (sint8 &i) { i = get_sint32 (); }
453     void get (uint8 &i) { i = get_sint32 (); }
454     void get (sint16 &i) { i = get_sint32 (); }
455     void get (uint16 &i) { i = get_sint32 (); }
456     void get (sint32 &i) { i = get_sint32 (); }
457    
458     void get (uint32 &i) { i = get_sint64 (); }
459     void get (sint64 &i) { i = get_sint64 (); }
460 root 1.53
461 root 1.89 MTH void parse_warn (const char *msg);
462     MTH bool parse_error (const char *type = 0, const char *name = 0, bool skip = true);
463    
464     struct delayed_ref {
465     attachable *op;
466     object_ptr *ptr;
467     const char *ref;
468     };
469     std::vector<delayed_ref> delrefs;
470    
471     void delayed_deref (attachable *op, object_ptr &ptr, const char *ref);
472     MTH void resolve_delayed_derefs (bool deref = true);
473 root 1.7 };
474 root 1.2
475 root 1.53 //TODO: remove
476 root 1.21 char *fgets (char *s, int n, object_thawer &thawer);
477    
478 root 1.42 //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
479    
480     struct coroapi {
481     static struct CoroAPI *GCoroAPI;
482    
483 root 1.94 static EV_ATOMIC_T cede_pending;
484 root 1.46
485 root 1.94 static int nready () { return CORO_NREADY; }
486     static int cede () { cede_pending = 0; return CORO_CEDE ; }
487 root 1.46
488 root 1.62 static void do_cede_to_tick ();
489 root 1.46
490 root 1.94 // actually cede's far more often
491 root 1.77 static bool cede_to_tick ()
492 root 1.62 {
493 root 1.94 if (expect_true (!cede_pending))
494 root 1.77 return false;
495    
496     do_cede_to_tick ();
497     return true;
498 root 1.62 }
499    
500 root 1.61 static void wait_for_tick ();
501     static void wait_for_tick_begin ();
502 root 1.42 };
503    
504 root 1.91 struct evapi
505 root 1.36 {
506 root 1.91 static struct EVAPI *GEVAPI;
507 root 1.36 };
508    
509 root 1.91 struct iow : ev_io, evapi, callback<void (iow &, int)>
510 root 1.36 {
511 root 1.92 static void thunk (EV_P_ struct ev_io *w_, int revents)
512 root 1.91 {
513     iow &w = *static_cast<iow *>(w_);
514    
515     w (w, revents);
516     }
517 root 1.36
518 root 1.91 template<class O, class M>
519     iow (O object, M method)
520     : callback<void (iow &, int)> (object, method)
521     {
522     ev_init ((ev_io *)this, thunk);
523     }
524 root 1.36
525 root 1.94 void prio (int prio)
526     {
527     ev_set_priority ((ev_io *)this, prio);
528     }
529    
530 root 1.91 void set (int fd, int events)
531 root 1.36 {
532 root 1.91 ev_io_set ((ev_io *)this, fd, events);
533 root 1.36 }
534    
535 root 1.91 int poll () const { return events; }
536    
537     void poll (int events);
538 root 1.36
539 root 1.91 void start ()
540 root 1.38 {
541 root 1.92 ev_io_start (EV_DEFAULT, (ev_io *)this);
542 root 1.38 }
543    
544 root 1.91 void stop ()
545     {
546 root 1.92 ev_io_stop (EV_DEFAULT, (ev_io *)this);
547 root 1.91 }
548 root 1.38
549 root 1.91 ~iow ()
550 root 1.36 {
551 root 1.91 stop ();
552 root 1.36 }
553     };
554    
555 root 1.94 struct asyncw : ev_async, evapi, callback<void (ev_async &, int)>
556     {
557     static void thunk (EV_P_ struct ev_async *w_, int revents)
558     {
559     asyncw &w = *static_cast<asyncw *>(w_);
560    
561     w (w, revents);
562     }
563    
564     template<class O, class M>
565     asyncw (O object, M method)
566     : callback<void (asyncw &, int)> (object, method)
567     {
568     ev_init ((ev_async *)this, thunk);
569     }
570    
571     void start ()
572     {
573     ev_async_start (EV_DEFAULT, (ev_async *)this);
574     }
575    
576     void stop ()
577     {
578     ev_async_stop (EV_DEFAULT, (ev_async *)this);
579     }
580    
581     ~asyncw ()
582     {
583     stop ();
584     }
585     };
586    
587 root 1.2 #endif
588 root 1.3