ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/Coro/Coro/MakeMaker.pm
Revision: 1.34
Committed: Fri Oct 2 19:55:59 2009 UTC (14 years, 8 months ago) by root
Branch: MAIN
CVS Tags: rel-5_2
Changes since 1.33: +1 -1 lines
Log Message:
*** empty log message ***

File Contents

# Content
1 package Coro::MakeMaker;
2
3 use common::sense;
4
5 use Config;
6 use base 'Exporter';
7
8 our $installsitearch;
9
10 our $VERSION = 5.2;
11 our @EXPORT_OK = qw(&coro_args $installsitearch);
12
13 my %opt;
14
15 for my $opt (split /:+/, $ENV{PERL_MM_OPT}) {
16 my ($k,$v) = split /=/, $opt;
17 $opt{$k} = $v;
18 }
19
20 my $extra = $Config{sitearch};
21
22 $extra =~ s/$Config{prefix}/$opt{PREFIX}/ if
23 exists $opt{PREFIX};
24
25 for my $d ($extra, @INC) {
26 if (-e "$d/Coro/CoroAPI.h") {
27 $installsitearch = $d;
28 last;
29 }
30 }
31
32 sub coro_args {
33 my %arg = @_;
34 $arg{INC} .= " -I$installsitearch/Coro";
35 %arg;
36 }
37
38 1;
39 __END__
40
41 =head1 NAME
42
43 Coro::MakeMaker - MakeMaker glue for the XS-level Coro API
44
45 =head1 SYNOPSIS
46
47 This allows you to control coroutines from C/XS.
48
49 =head1 DESCRIPTION
50
51 For optimal performance, hook into Coro at the C-level. You'll need to
52 make changes to your C<Makefile.PL> and add code to your C<xs> / C<c>
53 file(s).
54
55 =head1 WARNING
56
57 When you hook in at the C-level you can get a I<huge> performance gain,
58 but you also reduce the chances that your code will work unmodified with
59 newer versions of C<perl> or C<Coro>. This may or may not be a problem.
60 Just be aware, and set your expectations accordingly.
61
62 =head1 HOW TO
63
64 =head2 Makefile.PL
65
66 use Coro::MakeMaker qw(coro_args);
67
68 # ... set up %args ...
69
70 WriteMakefile (coro_args (%args));
71
72 =head2 XS
73
74 #include "CoroAPI.h"
75
76 BOOT:
77 I_CORO_API ("YourModule");
78
79 =head2 API
80
81 This is just a small overview - read the Coro/CoroAPI.h header file in
82 the distribution, and check the examples in F<EV/> and F<Event/*>, or
83 as a more real-world example, the Deliantra game server (which uses
84 Coro::MakeMaker).
85
86 #define CORO_TRANSFER(prev,next) /* transfer from prev to next */
87 #define CORO_SCHEDULE /* like Coro::schedule */
88 #define CORO_CEDE /* like Coro::cede */
89 #define CORO_CEDE_NOTSELF /* like Coro::cede_notself */
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 #define CORO_THROW /* exception pending? */
95 #define CORO_READYHOOK /* hook for event libs, see Coro::EV */
96
97 #define CORO_SV_STATE(coro) /* returns the internal struct coro * */
98 #define CORO_EXECUTE_SLF(cv,init,ax) /* execute a schedule-like function */
99 #define CORO_EXECUTE_SLF_XS(init) /* SLF in XS, see e.g. Coro::EV */
100
101 =cut