1 | TODO: if () acquire example |
|
|
2 | /* |
1 | /* |
3 | * Author: Marc A. Lehmann <xsthreadpool@schmorp.de> |
2 | * Author: Marc A. Lehmann <xsthreadpool@schmorp.de> |
4 | * License: public domain, or where this is not possible/at your option, |
3 | * License: public domain, or where this is not possible/at your option, |
5 | * CC0 (https://creativecommons.org/publicdomain/zero/1.0/) |
4 | * CC0 (https://creativecommons.org/publicdomain/zero/1.0/) |
6 | */ |
5 | */ |
7 | |
6 | |
8 | #ifndef PERL_MULTICORE_H |
7 | #ifndef PERL_MULTICORE_H |
9 | #define PERL_MULTICORE_H |
8 | #define PERL_MULTICORE_H |
10 | |
9 | |
11 | #if 0 |
10 | /* |
12 | |
|
|
13 | =head1 NAME |
11 | =head1 NAME |
14 | |
12 | |
15 | perlmulticore.h - release the perl interpreter for other uses while doing hard work |
13 | perlmulticore.h - release the perl interpreter for other uses while doing hard work |
16 | |
14 | |
17 | =head1 SYNOPSIS |
15 | =head1 SYNOPSIS |
… | |
… | |
59 | perl's built-in C<flock>, it allows other threads (for example, those |
57 | perl's built-in C<flock>, it allows other threads (for example, those |
60 | provided by L<Coro>) to execute, instead of blocking the whole perl |
58 | provided by L<Coro>) to execute, instead of blocking the whole perl |
61 | interpreter. For the sake of this example, it requires a file descriptor |
59 | interpreter. For the sake of this example, it requires a file descriptor |
62 | instead of a handle. |
60 | instead of a handle. |
63 | |
61 | |
64 | #include "perlmulticore.h" /* this header file */ |
62 | #include "perlmulticore.h" // this header file |
65 | |
63 | |
66 | // and in the XS portion |
64 | // and in the XS portion |
67 | int flock (int fd, int operation) |
65 | int flock (int fd, int operation) |
68 | CODE: |
66 | CODE: |
69 | perlinterp_release (); |
67 | perlinterp_release (); |
… | |
… | |
306 | The F<perlmulticore.h> is put into the public domain. Where this is legally |
304 | The F<perlmulticore.h> is put into the public domain. Where this is legally |
307 | not possible, or at your option, it can be licensed under creativecommons |
305 | not possible, or at your option, it can be licensed under creativecommons |
308 | CC0 license: L<https://creativecommons.org/publicdomain/zero/1.0/>. |
306 | CC0 license: L<https://creativecommons.org/publicdomain/zero/1.0/>. |
309 | |
307 | |
310 | =cut |
308 | =cut |
311 | |
309 | */ |
312 | #endif |
|
|
313 | |
310 | |
314 | struct perl_multicore_api |
311 | struct perl_multicore_api |
315 | { |
312 | { |
316 | void (*pmapi_release)(void); |
313 | void (*pmapi_release)(void); |
317 | void (*pmapi_acquire)(void); |
314 | void (*pmapi_acquire)(void); |