… | |
… | |
27 | |
27 | |
28 | In this module, coroutines are defined as "callchain + lexical variables |
28 | In this module, coroutines are defined as "callchain + lexical variables |
29 | + @_ + $_ + $@ + $^W), that is, a coroutine has it's own callchain, it's |
29 | + @_ + $_ + $@ + $^W), that is, a coroutine has it's own callchain, it's |
30 | own set of lexicals and it's own set of perl's most important global |
30 | own set of lexicals and it's own set of perl's most important global |
31 | variables. |
31 | variables. |
|
|
32 | |
|
|
33 | WARNING: When using this module, make sure that, at program end, no |
|
|
34 | coroutines are still running OR just call exit before falling off the |
|
|
35 | end. The reason for this is that some coroutine of yours might have called |
|
|
36 | into a C function, and falling off the end of main:: results in returning |
|
|
37 | to that C function instead if to the main C interpreter. |
32 | |
38 | |
33 | =cut |
39 | =cut |
34 | |
40 | |
35 | package Coro; |
41 | package Coro; |
36 | |
42 | |
… | |
… | |
174 | |
180 | |
175 | =cut |
181 | =cut |
176 | |
182 | |
177 | sub terminate { |
183 | sub terminate { |
178 | $current->{_results} = [@_]; |
184 | $current->{_results} = [@_]; |
|
|
185 | delete $current->{_coro_state}; |
179 | &schedule; |
186 | &schedule; |
180 | } |
187 | } |
181 | |
188 | |
182 | =back |
189 | =back |
183 | |
190 | |