… | |
… | |
33 | |
33 | |
34 | use base Exporter; |
34 | use base Exporter; |
35 | |
35 | |
36 | $VERSION = 0.09; |
36 | $VERSION = 0.09; |
37 | |
37 | |
38 | @EXPORT = qw(async yield schedule terminate); |
38 | @EXPORT = qw(async yield schedule terminate current); |
39 | @EXPORT_OK = qw($current); |
39 | @EXPORT_OK = qw($current); |
40 | |
40 | |
41 | { |
41 | { |
42 | use subs 'async'; |
42 | use subs 'async'; |
43 | |
43 | |
… | |
… | |
72 | |
72 | |
73 | =cut |
73 | =cut |
74 | |
74 | |
75 | our $main = new Coro; |
75 | our $main = new Coro; |
76 | |
76 | |
77 | =item $current |
77 | =item $current (or as function: current) |
78 | |
78 | |
79 | The current coroutine (the last coroutine switched to). The initial value is C<$main> (of course). |
79 | The current coroutine (the last coroutine switched to). The initial value is C<$main> (of course). |
80 | |
80 | |
81 | =cut |
81 | =cut |
82 | |
82 | |
… | |
… | |
84 | if ($current) { |
84 | if ($current) { |
85 | $main->{specific} = $current->{specific}; |
85 | $main->{specific} = $current->{specific}; |
86 | } |
86 | } |
87 | |
87 | |
88 | our $current = $main; |
88 | our $current = $main; |
|
|
89 | |
|
|
90 | sub current() { $current } |
89 | |
91 | |
90 | =item $idle |
92 | =item $idle |
91 | |
93 | |
92 | The coroutine to switch to when no other coroutine is running. The default |
94 | The coroutine to switch to when no other coroutine is running. The default |
93 | implementation prints "FATAL: deadlock detected" and exits. |
95 | implementation prints "FATAL: deadlock detected" and exits. |