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

Comparing Coro/Coro.pm (file contents):
Revision 1.1 by root, Tue Jul 3 02:53:34 2001 UTC vs.
Revision 1.2 by root, Tue Jul 3 03:40:07 2001 UTC

4 4
5=head1 SYNOPSIS 5=head1 SYNOPSIS
6 6
7 use Coro; 7 use Coro;
8 8
9 $new = new Coro sub {
10 print "in coroutine, switching back\n";
11 $Coro::main->resume;
12 print "in coroutine again, switching back\n";
13 $Coro::main->resume;
14 };
15
16 print "in main, switching to coroutine\n";
17 $new->resume;
18 print "back in main, switch to coroutine again\n";
19 $new->resume;
20 print "back in main\n";
21
9=head1 DESCRIPTION 22=head1 DESCRIPTION
23
24This module implements coroutines. Coroutines, similar to continuations,
25allow you to run more than one "thread of execution" in parallel. Unlike
26threads this, only voluntary switching is used so locking problems are
27greatly reduced.
28
29Although this is the "main" module of the Coro family it provides only
30low-level functionality. See L<Coro::Process> and related modules for a
31more useful process abstraction including scheduling.
10 32
11=over 4 33=over 4
12 34
13=cut 35=cut
14 36
45 67
46$error_msg = 68$error_msg =
47$error_coro = undef; 69$error_coro = undef;
48 70
49$error = _newprocess { 71$error = _newprocess {
50 print STDERR "FATAL: $error_msg, program aborted\n"; 72 print STDERR "FATAL: $error_msg\nprogram aborted\n";
51 exit 250; 73 exit 250;
52}; 74};
53 75
54=item $coro = new $coderef [, @args] 76=item $coro = new $coderef [, @args]
55 77
93 115
94=head1 BUGS 116=head1 BUGS
95 117
96This module has not yet been extensively tested. 118This module has not yet been extensively tested.
97 119
120=head1 SEE ALSO
121
122L<Coro::Process>, L<Coro::Signal>.
123
98=head1 AUTHOR 124=head1 AUTHOR
99 125
100 Marc Lehmann <pcg@goof.com> 126 Marc Lehmann <pcg@goof.com>
101 http://www.goof.com/pcg/marc/ 127 http://www.goof.com/pcg/marc/
102 128

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines