ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/cvsroot/Coro-Multicore/Multicore.pm
(Generate patch)

Comparing cvsroot/Coro-Multicore/Multicore.pm (file contents):
Revision 1.6 by root, Mon Jun 29 13:33:48 2015 UTC vs.
Revision 1.7 by root, Tue Jun 30 01:01:34 2015 UTC

8 8
9 # or, if you want it disabled by default (e.g. to use it from a module) 9 # or, if you want it disabled by default (e.g. to use it from a module)
10 use Coro::Multicore (); 10 use Coro::Multicore ();
11 11
12=head1 DESCRIPTION 12=head1 DESCRIPTION
13
14EXPERIMENTAL WARNING: This module is in its early stages of
15development. It's fine to try out, but it didn't receive the normal amount
16of testing and real-world usage that my other modules have gone through.
13 17
14While L<Coro> threads (unlike ithreads) provide real threads similar to 18While L<Coro> threads (unlike ithreads) provide real threads similar to
15pthreads, python threads and so on, they do not run in parallel to each 19pthreads, python threads and so on, they do not run in parallel to each
16other even on machines with multiple CPUs or multiple CPU cores. 20other even on machines with multiple CPUs or multiple CPU cores.
17 21
123 127
124our $WATCHER = AE::io fd, 0, \&poll; 128our $WATCHER = AE::io fd, 0, \&poll;
125 129
126=head1 INTERACTION WITH OTHER SOFTWARE 130=head1 INTERACTION WITH OTHER SOFTWARE
127 131
128TODO 132This module is very similar to other environments where perl interpreters
133are moved between threads, such as mod_perl2, and the same caveats apply.
134
135I want to spell out the most important ones:
136
137=over 4
138
139=item pthreads usage
140
141Any creation of pthreads make it impossible to fork portably from a
142perl program, as forking from within a threaded program will leave the
143program in a state similar to a signal handler. While it might work on
144some platforms (as an extension), this might also result in silent data
145corruption. It also seems to work most of the time, so it's hard to test
146for this.
147
148I recommend using something like L<AnyEvent::Fork>, which can create
149subprocesses safely (via L<Proc::FastSpawn>).
150
151Similar issues exist for signal handlers, although this module works hard
152to keep safe perl signals safe.
153
154=item module support
155
156This module moves the same perl interpreter between different
157threads. Some modules might get confused by that (although this can
158usually be considered a bug). This is a rare case though.
159
160=item event loop reliance
161
162To be able to wake up programs waiting for results, this module relies on
163an active event loop (via L<AnyEvent>). This is used to notify the perl
164interpreter when the asynchronous task is done.
165
166Since event loops typically fail to work properly after a fork, this means
167that some operations that were formerly working will now hang after fork.
168
169A workaround is to call C<Coro::Multicore::enable 0> after a fork to
170disable the module.
171
172Future versions of this module might do this automatically.
173
174=back
129 175
130=head1 BUGS 176=head1 BUGS
131 177
132=over 4 178=over 4
133 179
138the maximum number of concurrent asynchronous tasks, this will also limit 184the maximum number of concurrent asynchronous tasks, this will also limit
139the maximum number of threads created. 185the maximum number of threads created.
140 186
141Future versions will likely lift this limitation. 187Future versions will likely lift this limitation.
142 188
143=item AnyEvent is initalised on module load 189=item AnyEvent is initalised at module load time
144 190
145AnyEvent is initialised on module load, as opposed to at a later time. 191AnyEvent is initialised on module load, as opposed to at a later time.
146 192
147Future versions will likely change this. 193Future versions will likely change this.
148 194

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines