1 |
=head1 NAME |
2 |
|
3 |
Coro::Multicore - make coro threads on multiple cores with specially supported modules |
4 |
|
5 |
=head1 SYNOPSIS |
6 |
|
7 |
use Coro::Multicore; |
8 |
|
9 |
=head1 DESCRIPTION |
10 |
|
11 |
While L<Coro> threads (unlike ithreads) provide real threads similar to |
12 |
pthreads, python threads and so on, they do not run in parallel to eahc |
13 |
other even on machines with multiple CPUs or multiple CPU cores. |
14 |
|
15 |
This module lifts this restriction under two very specific but useful |
16 |
conditions: firstly, the coro thread executes in XS code and does not |
17 |
touch any perl data structures, and secondly, the XS code is specially |
18 |
prepared to allow this. |
19 |
|
20 |
This means that, when you call an XS function of a module prepared for it, |
21 |
this XS function can execute in parallel to any other Coro threads. |
22 |
|
23 |
The mechanism to support this is easily added to existing modules and is |
24 |
independent of L<Coro> or L<Coro::Multicore>, and therefore could be used, |
25 |
without changes, with other, similar, modules, or even the perl core, |
26 |
should it gain real thread support anytime soon. SEe L<TODO> for more info |
27 |
on how to prepare a module to allow parallel execution. |
28 |
|
29 |
=over 4 |
30 |
|
31 |
=cut |
32 |
|
33 |
package Coro::Multicore; |
34 |
|
35 |
use Coro (); |
36 |
use AnyEvent (); |
37 |
|
38 |
BEGIN { |
39 |
our $VERSION = 0.02; |
40 |
|
41 |
use XSLoader; |
42 |
XSLoader::load __PACKAGE__, $VERSION; |
43 |
} |
44 |
|
45 |
our $WATCHER = AE::io fd, 0, \&poll; |
46 |
|
47 |
=back |
48 |
|
49 |
=head1 AUTHOR |
50 |
|
51 |
Marc Lehmann <schmorp@schmorp.de> |
52 |
http://software.schmorp.de/pkg/AnyEvent-XSThreadPool.html |
53 |
|
54 |
=cut |
55 |
|
56 |
1 |
57 |
|