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

Comparing Coro/Coro.pm (file contents):
Revision 1.66 by root, Thu Mar 3 17:20:31 2005 UTC vs.
Revision 1.80 by root, Mon Nov 6 19:56:26 2006 UTC

30 30
31=cut 31=cut
32 32
33package Coro; 33package Coro;
34 34
35BEGIN { eval { require warnings } && warnings->unimport ("uninitialized") } 35use strict;
36no warnings "uninitialized";
36 37
37use Coro::State; 38use Coro::State;
38 39
39use vars qw($idle $main $current);
40
41use base Exporter; 40use base Exporter::;
42 41
43$VERSION = 1.11; 42our $idle; # idle coroutine
43our $main; # main coroutine
44our $current; # current coroutine
44 45
46our $VERSION = '2.5';
47
45@EXPORT = qw(async cede schedule terminate current); 48our @EXPORT = qw(async cede schedule terminate current);
46%EXPORT_TAGS = ( 49our %EXPORT_TAGS = (
47 prio => [qw(PRIO_MAX PRIO_HIGH PRIO_NORMAL PRIO_LOW PRIO_IDLE PRIO_MIN)], 50 prio => [qw(PRIO_MAX PRIO_HIGH PRIO_NORMAL PRIO_LOW PRIO_IDLE PRIO_MIN)],
48); 51);
49@EXPORT_OK = @{$EXPORT_TAGS{prio}}; 52our @EXPORT_OK = @{$EXPORT_TAGS{prio}};
50 53
51{ 54{
52 my @async; 55 my @async;
53 my $init; 56 my $init;
54 57
55 # this way of handling attributes simply is NOT scalable ;() 58 # this way of handling attributes simply is NOT scalable ;()
56 sub import { 59 sub import {
60 no strict 'refs';
61
57 Coro->export_to_level(1, @_); 62 Coro->export_to_level(1, @_);
63
58 my $old = *{(caller)[0]."::MODIFY_CODE_ATTRIBUTES"}{CODE}; 64 my $old = *{(caller)[0]."::MODIFY_CODE_ATTRIBUTES"}{CODE};
59 *{(caller)[0]."::MODIFY_CODE_ATTRIBUTES"} = sub { 65 *{(caller)[0]."::MODIFY_CODE_ATTRIBUTES"} = sub {
60 my ($package, $ref) = (shift, shift); 66 my ($package, $ref) = (shift, shift);
61 my @attrs; 67 my @attrs;
62 for (@_) { 68 for (@_) {
157 163
158Create a new asynchronous process and return it's process object 164Create a new asynchronous process and return it's process object
159(usually unused). When the sub returns the new process is automatically 165(usually unused). When the sub returns the new process is automatically
160terminated. 166terminated.
161 167
168When the coroutine dies, the program will exit, just as in the main
169program.
170
162 # create a new coroutine that just prints its arguments 171 # create a new coroutine that just prints its arguments
163 async { 172 async {
164 print "@_\n"; 173 print "@_\n";
165 } 1,2,3,4; 174 } 1,2,3,4;
166 175
235 244
236=cut 245=cut
237 246
238=item $process->cancel (arg...) 247=item $process->cancel (arg...)
239 248
240Temrinates the given process and makes it return the given arguments as 249Terminates the given process and makes it return the given arguments as
241status (default: the empty list). 250status (default: the empty list).
242 251
243=cut 252=cut
244 253
245sub cancel { 254sub cancel {
337 to allow per-thread schedulers, but Coro::State does not yet allow 346 to allow per-thread schedulers, but Coro::State does not yet allow
338 this). 347 this).
339 348
340=head1 SEE ALSO 349=head1 SEE ALSO
341 350
342L<Coro::Channel>, L<Coro::Cont>, L<Coro::Specific>, L<Coro::Semaphore>, 351Support/Utility: L<Coro::Cont>, L<Coro::Specific>, L<Coro::State>, L<Coro::Util>.
343L<Coro::Signal>, L<Coro::State>, L<Coro::Timer>, L<Coro::Event>, 352
344L<Coro::Handle>, L<Coro::RWLock>, L<Coro::Socket>. 353Locking/IPC: L<Coro::Signal>, L<Coro::Channel>, L<Coro::Semaphore>, L<Coro::SemaphoreSet>, L<Coro::RWLock>.
354
355Event/IO: L<Coro::Timer>, L<Coro::Event>, L<Coro::Handle>, L<Coro::Socket>, L<Coro::Select>.
356
357Embedding: L<Coro:MakeMaker>
345 358
346=head1 AUTHOR 359=head1 AUTHOR
347 360
348 Marc Lehmann <schmorp@schmorp.de> 361 Marc Lehmann <schmorp@schmorp.de>
349 http://home.schmorp.de/ 362 http://home.schmorp.de/

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines