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

Comparing Coro/Coro/Handle.pm (file contents):
Revision 1.27 by root, Mon Mar 19 14:14:23 2007 UTC vs.
Revision 1.28 by root, Tue Oct 9 14:07:01 2007 UTC

13 13
14It does so by using L<AnyEvent|AnyEvent> to wait for readable/writable 14It does so by using L<AnyEvent|AnyEvent> to wait for readable/writable
15data, allowing other coroutines to run while one coroutine waits for I/O. 15data, allowing other coroutines to run while one coroutine waits for I/O.
16 16
17Coro::Handle does NOT inherit from IO::Handle but uses tied objects. 17Coro::Handle does NOT inherit from IO::Handle but uses tied objects.
18
19If at all possible, you should I<always> prefer method calls on the handle object over invoking
20tied methods, i.e.:
21
22 $fh->print ($str); # NOT print $fh $str;
23 my $line = $fh->readline; # NOT my $line = <$fh>;
24
25The reason is that perl recurses within the interpreter when invoking tie
26magic, forcing the (temporary) allocation of a (big) stack. If you have
27lots of socket connections and they happen to wait in e.g. <$fh>, then
28they would all have a costly C coroutine associated with them.
18 29
19=over 4 30=over 4
20 31
21=cut 32=cut
22 33

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines