1MakeMaker(3) User Contributed Perl Documentation MakeMaker(3)
2
3
4
6 Coro::MakeMaker - MakeMaker glue for the XS-level Coro API
7
9 This allows you to control coroutines from C/XS.
10
12 For optimal performance, hook into Coro at the C-level. You'll need to
13 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 can get a huge performance gain,
18 but you also reduce the chances that your code will work unmodified
19 with newer versions of "perl" or "Coro". This may or may not be a
20 problem. Just be aware, and set your expectations accordingly.
21
23 Makefile.PL
24 use Coro::MakeMaker qw(coro_args);
25
26 # ... set up %args ...
27
28 WriteMakefile (coro_args (%args));
29
30 XS
31 #include "CoroAPI.h"
32
33 BOOT:
34 I_CORO_API ("YourModule");
35
36 API
37 This is just a small overview - read the Coro/CoroAPI.h header file in
38 the distribution, and check the examples in EV/ and Event/*, or as a
39 more real-world example, the Deliantra game server (which uses
40 Coro::MakeMaker).
41
42 You can also drop me a mail if you run into any trouble.
43
44 #define CORO_TRANSFER(prev,next) /* transfer from prev to next */
45 #define CORO_SCHEDULE /* like Coro::schedule */
46 #define CORO_CEDE /* like Coro::cede */
47 #define CORO_CEDE_NOTSELF /* like Coro::cede_notself */
48 #define CORO_READY(coro) /* like $coro->ready */
49 #define CORO_IS_READY(coro) /* like $coro->is_ready */
50 #define CORO_NREADY /* # of procs in ready queue */
51 #define CORO_CURRENT /* returns $Coro::current */
52 #define CORO_THROW /* exception pending? */
53 #define CORO_READYHOOK /* hook for event libs, see Coro::EV */
54
55 /* C-level coroutine struct, opaque, not used much */
56 struct coro;
57
58 /* used for schedule-like-function prepares */
59 struct coro_transfer_args
60 {
61 struct coro *prev, *next;
62 };
63
64 /* this is the per-perl-coro slf frame info */
65 struct CoroSLF
66 {
67 void (*prepare) (pTHX_ struct coro_transfer_args *ta); /* 0 means not yet initialised */
68 int (*check) (pTHX_ struct CoroSLF *frame);
69 void *data; /* for use by prepare/check/destroy */
70 void (*destroy) (pTHX_ struct CoroSLF *frame);
71 };
72
73 /* needs to fill in the *frame */
74 typedef void (*coro_slf_cb) (pTHX_ struct CoroSLF *frame, CV *cv, SV **arg, int items);
75
76 #define CORO_SV_STATE(coro) /* returns the internal struct coro * */
77 #define CORO_EXECUTE_SLF(cv,init,ax) /* execute a schedule-like function */
78 #define CORO_EXECUTE_SLF_XS(init) /* SLF in XS, see e.g. Coro::EV */
79
80 /* called on enter/leave */
81 typedef void (*coro_enterleave_hook) (pTHX_ void *arg);
82
83 #define CORO_ENTERLEAVE_HOOK(coro,enter,enter_arg,leave,leave_arg) /* install an XS-level enter/leave hook */
84 #define CORO_ENTERLEAVE_UNHOOK(coro,enter,leave) /* remove an XS-level enter/leave hook */
85 #define CORO_ENTERLEAVE_SCOPE_HOOK(enter,enter_arg,leave,leave_arg) /* install an XS-level enter/leave hook for the corrent scope */
86
88 Marc A. Lehmann <schmorp@schmorp.de>
89 http://software.schmorp.de/pkg/Coro.html
90
91
92
93perl v5.32.0 2020-08-03 MakeMaker(3)