| 1 |
package Coro::MakeMaker; |
| 2 |
|
| 3 |
no warnings; |
| 4 |
|
| 5 |
use Config; |
| 6 |
use base 'Exporter'; |
| 7 |
|
| 8 |
@EXPORT_OK = qw(&coro_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/Coro/CoroAPI.h") { |
| 24 |
$installsitearch = $d; |
| 25 |
last; |
| 26 |
} |
| 27 |
} |
| 28 |
|
| 29 |
sub coro_args { |
| 30 |
my %arg = @_; |
| 31 |
$arg{INC} .= " -I$installsitearch/Coro"; |
| 32 |
%arg; |
| 33 |
} |
| 34 |
|
| 35 |
1; |
| 36 |
__END__ |
| 37 |
|
| 38 |
=head1 NAME |
| 39 |
|
| 40 |
Coro::MakeMaker - MakeMaker glue for the C-level Coro API |
| 41 |
|
| 42 |
=head1 SYNOPSIS |
| 43 |
|
| 44 |
This allows you to control coroutines from C level. |
| 45 |
|
| 46 |
=head1 DESCRIPTION |
| 47 |
|
| 48 |
For optimal performance, hook into Coro at the C-level. You'll need |
| 49 |
to make changes to your C<Makefile.PL> and add code to your C<xs> / |
| 50 |
C<c> file(s). |
| 51 |
|
| 52 |
=head1 WARNING |
| 53 |
|
| 54 |
When you hook in at the C-level you get a I<huge> performance gain, |
| 55 |
but you also reduce the chances that your code will work unmodified |
| 56 |
with newer versions of C<perl> or C<Coro>. This may or may not be a |
| 57 |
problem. Just be aware, and set your expectations accordingly. |
| 58 |
|
| 59 |
=head1 HOW TO |
| 60 |
|
| 61 |
=head2 Makefile.PL |
| 62 |
|
| 63 |
use Coro::MakeMaker qw(coro_args); |
| 64 |
|
| 65 |
# ... set up %args ... |
| 66 |
|
| 67 |
WriteMakefile(coro_args(%args)); |
| 68 |
|
| 69 |
=head2 XS |
| 70 |
|
| 71 |
#include "CoroAPI.h" |
| 72 |
|
| 73 |
BOOT: |
| 74 |
I_CORO_API("YourModule"); |
| 75 |
|
| 76 |
=head2 API (v21) |
| 77 |
|
| 78 |
struct CoroAPI { |
| 79 |
I32 Ver; |
| 80 |
|
| 81 |
}; |
| 82 |
|
| 83 |
=cut |