… | |
… | |
37 | Please note that even programs or modules (such as |
37 | Please note that even programs or modules (such as |
38 | L<Coro::Handle|Coro::Handle>) that use "traditional" |
38 | L<Coro::Handle|Coro::Handle>) that use "traditional" |
39 | event-based/continuation style will run more efficient with this module |
39 | event-based/continuation style will run more efficient with this module |
40 | then when using only Event. |
40 | then when using only Event. |
41 | |
41 | |
|
|
42 | =head1 WARNING |
|
|
43 | |
|
|
44 | Please note that Event does not support coroutines or threads. That |
|
|
45 | means that you B<MUST NOT> block in an event callback. Again: In Event |
|
|
46 | callbacks, you I<must never ever> call a Coroutine fucntion that blocks |
|
|
47 | the current coroutine. |
|
|
48 | |
|
|
49 | While this seems to work superficially, it will eventually cause memory |
|
|
50 | corruption. |
|
|
51 | |
|
|
52 | =head1 FUNCTIONS |
|
|
53 | |
42 | =over 4 |
54 | =over 4 |
43 | |
55 | |
44 | =cut |
56 | =cut |
45 | |
57 | |
46 | package Coro::Event; |
58 | package Coro::Event; |
47 | |
59 | |
48 | BEGIN { eval { require warnings } && warnings->unimport ("uninitialized") } |
60 | no warnings; |
49 | |
61 | |
50 | use Carp; |
62 | use Carp; |
51 | no warnings; |
63 | no warnings; |
52 | |
64 | |
53 | use Coro; |
65 | use Coro; |
… | |
… | |
65 | |
77 | |
66 | local $^W = 0; # avoid redefine warning for Coro::ready; |
78 | local $^W = 0; # avoid redefine warning for Coro::ready; |
67 | XSLoader::load __PACKAGE__, $VERSION; |
79 | XSLoader::load __PACKAGE__, $VERSION; |
68 | } |
80 | } |
69 | |
81 | |
70 | =item $w = Coro::Event->flavour(args...) |
82 | =item $w = Coro::Event->flavour (args...) |
71 | |
83 | |
72 | Create and return a watcher of the given type. |
84 | Create and return a watcher of the given type. |
73 | |
85 | |
74 | Examples: |
86 | Examples: |
75 | |
87 | |
… | |
… | |
82 | |
94 | |
83 | Return the next event of the event queue of the watcher. |
95 | Return the next event of the event queue of the watcher. |
84 | |
96 | |
85 | =cut |
97 | =cut |
86 | |
98 | |
87 | =item do_flavour(args...) |
99 | =item do_flavour args... |
88 | |
100 | |
89 | Create a watcher of the given type and immediately call it's next |
101 | Create a watcher of the given type and immediately call it's next |
90 | method. This is less efficient then calling the constructor once and the |
102 | method. This is less efficient then calling the constructor once and the |
91 | next method often, but it does save typing sometimes. |
103 | next method often, but it does save typing sometimes. |
92 | |
104 | |
… | |
… | |
147 | into the Event dispatcher. |
159 | into the Event dispatcher. |
148 | |
160 | |
149 | =cut |
161 | =cut |
150 | |
162 | |
151 | sub sweep { |
163 | sub sweep { |
152 | Event::one_event(0); # for now |
164 | Event::one_event 0; # for now |
153 | } |
165 | } |
154 | |
166 | |
155 | =item $result = loop([$timeout]) |
167 | =item $result = loop([$timeout]) |
156 | |
168 | |
157 | This is the version of C<loop> you should use instead of C<Event::loop> |
169 | This is the version of C<loop> you should use instead of C<Event::loop> |