Revision: | 1.6 |
Committed: | Fri Dec 1 02:17:37 2006 UTC (17 years, 6 months ago) by root |
Branch: | MAIN |
CVS Tags: | rel-4_22, rel-4_21, rel-4_0, rel-4_3, rel-3_41, rel-4_13, rel-4_11, rel-3_55, rel-3_51, rel-4_01, rel-4_03, rel-4_02, rel-3_6, rel-3_62, rel-3_63, rel-3_61, rel-3_4, rel-3_1, rel-3_5, rel-3_3, rel-3_2, rel-3_0, rel-3_01, rel-4_50, rel-4_51, rel-4_4, rel-3_11, rel-4_45, rel-4_49, rel-4_48, rel-4_1, rel-4_2, rel-4_47, rel-4_46, rel-3_501, rel-4_31, rel-4_32, rel-4_33, rel-4_34, rel-4_35, rel-4_36, rel-4_37 |
Changes since 1.5: | +5 -6 lines |
Log Message: | *** empty log message *** |
# | Content |
---|---|
1 | package Coro::MakeMaker; |
2 | |
3 | BEGIN { eval { require warnings } && warnings->unimport ("uninitialized") } |
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 |
77 | |
78 | /* perl-related */ |
79 | #define TRANSFER_SAVE_DEFAV /* save @_ */ |
80 | #define TRANSFER_SAVE_DEFSV /* save $_ */ |
81 | #define TRANSFER_SAVE_ERRSV /* save $@ */ |
82 | |
83 | #define TRANSFER_SAVE_ALL ( TRANSFER_SAVE_DEFAV \ |
84 | | TRANSFER_SAVE_DEFSV \ |
85 | | TRANSFER_SAVE_ERRSV) |
86 | |
87 | #define CORO_TRANSFER(prev,next,flags) /* transfer from prev to next */ |
88 | #define CORO_SCHEDULE /* like Coro::schedule */ |
89 | #define CORO_CEDE /* like Coro::cede */ |
90 | #define CORO_READY(coro) /* like $coro->ready */ |
91 | #define CORO_IS_READY(coro) /* like $coro->is_ready */ |
92 | #define CORO_NREADY /* # of procs in ready queue */ |
93 | #define CORO_CURRENT /* returns $Coro::current */ |
94 | |
95 | =cut |