ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/EV/EV/MakeMaker.pm
Revision: 1.12
Committed: Tue Apr 17 18:51:05 2018 UTC (6 years ago) by root
Branch: MAIN
CVS Tags: EV-rel-4_28, EV-rel-4_29, EV-rel-4_26, EV-rel-4_27, EV-rel-4_25, EV-rel-4_31, EV-rel-4_30, EV-rel-4_33, EV-rel-4_32, EV-rel-4_34, HEAD
Changes since 1.11: +4 -4 lines
Log Message:
*** empty log message ***

File Contents

# Content
1 package EV::MakeMaker;
2
3 BEGIN { eval { require warnings } && warnings->unimport ("uninitialized") }
4
5 use Config;
6 use base 'Exporter';
7
8 @EXPORT_OK = qw(&ev_args $installsitearch);
9
10 my %opt;
11
12 for my $opt (split /:+/, $ENV{PERL_MM_OPT}) {
13 my ($k,$v) = split /=/, $opt;
14 $opt{$k} = $v;
15 }
16
17 my $extra = $Config{sitearch};
18
19 $extra =~ s/$Config{prefix}/$opt{PREFIX}/ if
20 exists $opt{PREFIX};
21
22 for my $d ($extra, @INC) {
23 if (-e "$d/EV/EVAPI.h") {
24 $installsitearch = $d;
25 last;
26 }
27 }
28
29 sub ev_args {
30 my %arg = @_;
31 $arg{INC} .= " -I$installsitearch/EV -I$installsitearch";
32 %arg;
33 }
34
35 1;
36 __END__
37
38 =head1 NAME
39
40 EV::MakeMaker - MakeMaker glue for the C-level EV API
41
42 =head1 SYNOPSIS
43
44 This allows you to access some libevent functionality from other perl
45 modules.
46
47 =head1 DESCRIPTION
48
49 For optimal performance, hook into EV at the C-level. You'll need to make
50 changes to your C<Makefile.PL>, load C<EV> in your C<pm> file and add
51 code to your C<xs> / C<c> file(s).
52
53 =head1 HOW TO
54
55 =head2 Makefile.PL
56
57 use EV::MakeMaker qw(ev_args);
58
59 # ... set up %args ...
60
61 WriteMakefile (ev_args (%args));
62
63 =head2 extension.pm
64
65 use EV (); # imports optional
66
67 =head2 extension.xs
68
69 #include "EVAPI.h"
70
71 [...]
72
73 BOOT:
74 I_EV_API (HvNAME (GvSTASH (CvGV (cv))));
75
76 =head1 API
77
78 See the L<EVAPI.h|http://cvs.schmorp.de/EV/EV/EVAPI.h> header, which you
79 should include instead of F<ev.h>.
80
81 In short, all the functions and macros from F<ev.h> should work, except
82 that the trailing underscore macros (C<EV_A_>, C<EV_DEFAULT_>) are not
83 available (except C<EV_P_> :).
84
85 Multiplicity is enabled.
86
87 The C<data> member in each watcher is of type C<SV *> and not C<void *>
88 (this might change at some point).
89
90 =head1 EXAMPLE
91
92 The L<EV::Glib>, L<EV::ADNS> and L<Glib::EV> modules all give nice
93 examples on how to use this module.
94
95 Here are some F<.xs> fragments taken from EV::ADNS that should get you
96 going:
97
98 #include "EVAPI.h"
99
100 static ev_prepare pw;
101 static ev_idle iw;
102
103 static void
104 idle_cb (EV_P_ ev_idle *w, int revents)
105 {
106 ev_idle_stop (EV_A, w);
107 }
108
109 MODULE = ...
110
111 BOOT:
112 {
113 I_EV_API ("EV::ADNS");
114 ev_prepare_init (&pw, prepare_cb);
115 ev_init (&iw, idle_cb); ev_set_priority (&iw, EV_MINPRI);
116 ev_idle_start (EV_DEFAULT, &iw);
117 }
118
119 =cut
120