1Event::MakeMaker(3) User Contributed Perl Documentation Event::MakeMaker(3)
2
3
4
6 Event::MakeMaker - MakeMaker glue for the C-level Event API
7
9 This is an advanced feature of Event.
10
12 For optimal performance, hook into Event at the C-level. You'll need
13 to make changes to your "Makefile.PL" and add code to your "xs" / "c"
14 file(s).
15
17 When you hook in at the C-level you get a huge performance gain, but
18 you also reduce the chances that your code will work unmodified with
19 newer versions of "perl" or "Event". This may or may not be a problem.
20 Just be aware, and set your expectations accordingly.
21
23 Makefile.PL
24
25 use Event::MakeMaker qw(event_args);
26
27 # ... set up %args ...
28
29 WriteMakefile(event_args(%args));
30
31 XS
32
33 #include "EventAPI.h"
34
35 BOOT:
36 I_EVENT_API("YourModule");
37
38 API (v21)
39
40 struct EventAPI {
41 I32 Ver;
42
43 /* EVENTS */
44 void (*queue )(pe_event *ev);
45 void (*start )(pe_watcher *ev, int repeat);
46 void (*now )(pe_watcher *ev);
47 void (*stop )(pe_watcher *ev, int cancel_events);
48 void (*cancel )(pe_watcher *ev);
49 void (*suspend )(pe_watcher *ev);
50 void (*resume )(pe_watcher *ev);
51
52 /* All constructors optionally take a stash and template. Either
53 or both can be NULL. The template should not be a reference. */
54 pe_idle *(*new_idle )(HV*, SV*);
55 pe_timer *(*new_timer )(HV*, SV*);
56 pe_io *(*new_io )(HV*, SV*);
57 pe_var *(*new_var )(HV*, SV*);
58 pe_signal *(*new_signal)(HV*, SV*);
59
60 /* TIMEABLE */
61 void (*tstart)(pe_timeable *);
62 void (*tstop)(pe_timeable *);
63
64 /* HOOKS */
65 pe_qcallback *(*add_hook)(char *which, void *cb, void *ext_data);
66 void (*cancel_hook)(pe_qcallback *qcb);
67
68 /* STATS */
69 void (*install_stats)(pe_event_stats_vtbl *esvtbl);
70 void (*collect_stats)(int yes);
71 pe_ring *AllWatchers;
72
73 /* TYPEMAP */
74 SV *(*watcher_2sv)(pe_watcher *wa);
75 void *(*sv_2watcher)(SV *sv);
76 SV *(*event_2sv)(pe_event *ev);
77 void *(*sv_2event)(SV *sv);
78 };
79
80 EXAMPLE
81
82 static pe_io *X11_ev=0;
83
84 static void x_server_dispatch(void *ext_data)
85 { ... }
86
87 if (!X11_ev) {
88 X11_ev = GEventAPI->new_io(0,0);
89 X11_ev->poll = PE_R;
90 sv_setpv(X11_ev->base.desc, "X::Server");
91 X11_ev->base.callback = (void*) x_server_dispatch;
92 X11_ev->base.ext_data = <whatever>;
93 X11_ev->base.prio = PE_PRIO_NORMAL;
94 }
95 X11_ev->fd = x_fd;
96 GEventAPI->resume((pe_event*) X11_ev);
97 GEventAPI->start((pe_event*) X11_ev, 0);
98
99 BUT I NEED A NEW TYPE OF WATCHER FOR MY INTERGALACTIC INFEROMETER
100
101 I'd prefer not to export the entire Event.h apparatus in favor of mini‐
102 mizing interdependencies. If you really, really need to create a new
103 type of watcher send your problem analysis to the mailing list!
104
105
106
107perl v5.8.8 2007-05-22 Event::MakeMaker(3)