1 typedef int IOM_CHAINED;
4 iom_new_ref (HV *hv, const char *klass)
6 return sv_bless (newRV ((SV *)hv), gv_stashpv (klass, 1));
9 /////////////////////////////////////////////////////////////////////////////
11 #define SvWATCHER(sv) (perl_watcher *)SvPTR (sv, IOM_CLASS "::watcher")
34 void invoke (const char *type, SV *self, int arg = -1);
38 perl_watcher::invoke (const char *type, SV *self, int arg)
47 XPUSHs (sv_2mortal (self));
50 XPUSHs (sv_2mortal (newSViv (arg)));
53 call_sv (cbsv, G_VOID | G_EVAL | G_DISCARD);
61 IOM_WARN ("%s callback evaluation error: %s", type, SvPV_nolen (ERRSV));
64 #define newSVtimer(timer) iom_new_ref ((timer)->self, IOM_CLASS "::timer")
65 #define SvTIMER(sv) (timer *)(perl_watcher *)SvPTR ((sv), IOM_CLASS "::timer")
67 struct timer : perl_watcher, ev::timer
71 set<timer, &timer::execute> (this);
74 void execute (ev::timer &w, int revents)
76 invoke (IOM_CLASS "::timer", newSVtimer (this));
80 #define newSViow(iow) iom_new_ref ((iow)->self, IOM_CLASS "::iow")
81 #define SvIOW(sv) (iow *)(perl_watcher *)SvPTR ((sv), IOM_CLASS "::iow")
83 struct iow : perl_watcher, ev::io
87 set<iow, &iow::execute> (this);
90 void execute (ev::io &w, int revents)
92 invoke (IOM_CLASS "::iow", newSViow (this), revents);
96 #define newSViw(iw) iom_new_ref ((iw)->self, IOM_CLASS "::iw")
97 #define SvIW(sv) (iw *)(perl_watcher *)SvPTR ((sv), IOM_CLASS "::iw")
99 struct iw : perl_watcher, ev::idle
103 set<iw, &iw::execute> (this);
106 void execute (ev::idle &w, int revents)
108 invoke (IOM_CLASS "::iw", newSViw (this));
112 #define newSVpw(pw) iom_new_ref ((pw)->self, IOM_CLASS "::pw")
113 #define SvPW(sv) (pw *)(perl_watcher *)SvPTR ((sv), IOM_CLASS "::pw")
115 struct pw : perl_watcher, ev::child
119 set<pw, &pw::execute> (this);
122 void execute (ev::child &w, int revents)
124 invoke (IOM_CLASS "::pw", newSVpw (this), w.rstatus);