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

Comparing Coro/README (file contents):
Revision 1.4 by root, Sun Dec 3 21:59:53 2006 UTC vs.
Revision 1.5 by root, Mon Dec 4 22:06:02 2006 UTC

16 16
17 cede; 17 cede;
18 18
19DESCRIPTION 19DESCRIPTION
20 This module collection manages coroutines. Coroutines are similar to 20 This module collection manages coroutines. Coroutines are similar to
21 threads but don't run in parallel. 21 threads but don't run in parallel at the same time even on SMP machines.
22 The specific flavor of coroutine use din this module also guarentees you
23 that it will not switch between coroutines unless necessary, at
24 easily-identified points in your program, so locking and parallel access
25 are rarely an issue, making coroutine programming much safer than
26 threads programming.
27
28 (Perl, however, does not natively support real threads but instead does
29 a very slow and memory-intensive emulation of processes using threads.
30 This is a performance win on Windows machines, and a loss everywhere
31 else).
22 32
23 In this module, coroutines are defined as "callchain + lexical variables 33 In this module, coroutines are defined as "callchain + lexical variables
24 + @_ + $_ + $@ + $^W + C stack), that is, a coroutine has it's own 34 + @_ + $_ + $@ + $/ + C stack), that is, a coroutine has its own
25 callchain, it's own set of lexicals and it's own set of perl's most 35 callchain, its own set of lexicals and its own set of perls most
26 important global variables. 36 important global variables.
27 37
28 $main 38 $main
29 This coroutine represents the main program. 39 This coroutine represents the main program.
30 40
164 $olddesc = $coroutine->desc ($newdesc) 174 $olddesc = $coroutine->desc ($newdesc)
165 Sets (or gets in case the argument is missing) the description for 175 Sets (or gets in case the argument is missing) the description for
166 this coroutine. This is just a free-form string you can associate 176 this coroutine. This is just a free-form string you can associate
167 with a coroutine. 177 with a coroutine.
168 178
169 UTILITY FUNCTIONS 179 GLOBAL FUNCTIONS
180 Coro::nready
181 Returns the number of coroutines that are currently in the ready
182 state, i.e. that can be swicthed to. The value 0 means that the only
183 runnable coroutine is the currently running one, so "cede" would
184 have no effect, and "schedule" would cause a deadlock unless there
185 is an idle handler that wakes up some coroutines.
186
170 unblock_sub { ... } 187 unblock_sub { ... }
171 This utility function takes a BLOCK or code reference and "unblocks" 188 This utility function takes a BLOCK or code reference and "unblocks"
172 it, returning the new coderef. This means that the new coderef will 189 it, returning the new coderef. This means that the new coderef will
173 return immediately without blocking, returning nothing, while the 190 return immediately without blocking, returning nothing, while the
174 original code ref will be called (with parameters) from within its 191 original code ref will be called (with parameters) from within its

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines