.\" -*- mode: troff; coding: utf-8 -*- .\" Automatically generated by Pod::Man 5.01 (Pod::Simple 3.43) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" \*(C` and \*(C' are quotes in nroff, nothing in troff, for use with C<>. .ie n \{\ . ds C` "" . ds C' "" 'br\} .el\{\ . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" ======================================================================== .\" .IX Title "Event::MakeMaker 3pm" .TH Event::MakeMaker 3pm 2024-03-07 "perl v5.38.2" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH NAME Event::MakeMaker \- MakeMaker glue for the C\-level Event API .SH SYNOPSIS .IX Header "SYNOPSIS" This is an advanced feature of Event. .SH DESCRIPTION .IX Header "DESCRIPTION" For optimal performance, hook into Event at the C\-level. You'll need to make changes to your \f(CW\*(C`Makefile.PL\*(C'\fR and add code to your \f(CW\*(C`xs\*(C'\fR / \&\f(CW\*(C`c\*(C'\fR file(s). .SH WARNING .IX Header "WARNING" When you hook in at the C\-level you get a \fIhuge\fR performance gain, but you also reduce the chances that your code will work unmodified with newer versions of \f(CW\*(C`perl\*(C'\fR or \f(CW\*(C`Event\*(C'\fR. This may or may not be a problem. Just be aware, and set your expectations accordingly. .SH "HOW TO" .IX Header "HOW TO" .SS Makefile.PL .IX Subsection "Makefile.PL" .Vb 1 \& use Event::MakeMaker qw(event_args); \& \& # ... set up %args ... \& \& WriteMakefile(event_args(%args)); .Ve .SS XS .IX Subsection "XS" .Vb 1 \& #include "EventAPI.h" \& \& BOOT: \& I_EVENT_API("YourModule"); .Ve .SS "API (v21)" .IX Subsection "API (v21)" .Vb 2 \& struct EventAPI { \& I32 Ver; \& \& /* EVENTS */ \& void (*queue )(pe_event *ev); \& void (*start )(pe_watcher *ev, int repeat); \& void (*now )(pe_watcher *ev); \& void (*stop )(pe_watcher *ev, int cancel_events); \& void (*cancel )(pe_watcher *ev); \& void (*suspend )(pe_watcher *ev); \& void (*resume )(pe_watcher *ev); \& \& /* All constructors optionally take a stash and template. Either \& or both can be NULL. The template should not be a reference. */ \& pe_idle *(*new_idle )(HV*, SV*); \& pe_timer *(*new_timer )(HV*, SV*); \& pe_io *(*new_io )(HV*, SV*); \& pe_var *(*new_var )(HV*, SV*); \& pe_signal *(*new_signal)(HV*, SV*); \& \& /* TIMEABLE */ \& void (*tstart)(pe_timeable *); \& void (*tstop)(pe_timeable *); \& \& /* HOOKS */ \& pe_qcallback *(*add_hook)(char *which, void *cb, void *ext_data); \& void (*cancel_hook)(pe_qcallback *qcb); \& \& /* STATS */ \& void (*install_stats)(pe_event_stats_vtbl *esvtbl); \& void (*collect_stats)(int yes); \& pe_ring *AllWatchers; \& \& /* TYPEMAP */ \& SV *(*watcher_2sv)(pe_watcher *wa); \& void *(*sv_2watcher)(SV *sv); \& SV *(*event_2sv)(pe_event *ev); \& void *(*sv_2event)(SV *sv); \& }; .Ve .SS EXAMPLE .IX Subsection "EXAMPLE" .Vb 1 \& static pe_io *X11_ev=0; \& \& static void x_server_dispatch(void *ext_data) \& { ... } \& \& if (!X11_ev) { \& X11_ev = GEventAPI\->new_io(0,0); \& X11_ev\->poll = PE_R; \& sv_setpv(X11_ev\->base.desc, "X::Server"); \& X11_ev\->base.callback = (void*) x_server_dispatch; \& X11_ev\->base.ext_data = ; \& X11_ev\->base.prio = PE_PRIO_NORMAL; \& } \& X11_ev\->fd = x_fd; \& GEventAPI\->resume((pe_event*) X11_ev); \& GEventAPI\->start((pe_event*) X11_ev, 0); .Ve .SS "BUT I NEED A NEW TYPE OF WATCHER FOR MY INTERGALACTIC INFEROMETER" .IX Subsection "BUT I NEED A NEW TYPE OF WATCHER FOR MY INTERGALACTIC INFEROMETER" I'd prefer not to export the entire Event.h apparatus in favor of minimizing interdependencies. If you really, really need to create a new type of watcher send your problem analysis to the mailing list!