… | |
… | |
16 | |
16 | |
17 | =cut |
17 | =cut |
18 | |
18 | |
19 | package Coro::Handle; |
19 | package Coro::Handle; |
20 | |
20 | |
21 | no warnings; |
21 | no warnings qw(uninitialized); |
22 | |
22 | |
23 | use Errno (); |
23 | use Errno (); |
24 | use base 'Exporter'; |
24 | use base 'Exporter'; |
25 | |
25 | |
26 | $VERSION = 0.45; |
26 | $VERSION = 0.45; |
… | |
… | |
130 | |
130 | |
131 | Returns the "real" (non-blocking) filehandle. Use this if you want to |
131 | Returns the "real" (non-blocking) filehandle. Use this if you want to |
132 | do operations on the file handle you cannot do using the Coro::Handle |
132 | do operations on the file handle you cannot do using the Coro::Handle |
133 | interface. |
133 | interface. |
134 | |
134 | |
|
|
135 | =item $fh->unsysread($data) |
|
|
136 | |
|
|
137 | Pushes the given data into the input buffer. The following calls to |
|
|
138 | read/sysread will first return this data. |
|
|
139 | |
135 | =cut |
140 | =cut |
136 | |
141 | |
137 | sub fh { |
142 | sub fh { |
138 | tied(${$_[0]})->{fh}; |
143 | (tied ${$_[0]})->[0]; |
|
|
144 | } |
|
|
145 | |
|
|
146 | sub unsysread { |
|
|
147 | substr tied(${$_[0]})->[3], 0, 0, $_[1]; |
139 | } |
148 | } |
140 | |
149 | |
141 | package Coro::Handle::FH; |
150 | package Coro::Handle::FH; |
142 | |
151 | |
143 | no warnings; |
152 | no warnings qw(uninitialized); |
144 | |
153 | |
145 | use Fcntl (); |
154 | use Fcntl (); |
146 | use Errno (); |
155 | use Errno (); |
147 | use Carp 'croak'; |
156 | use Carp 'croak'; |
148 | |
157 | |
… | |
… | |
154 | # |
163 | # |
155 | # 0 FH |
164 | # 0 FH |
156 | # 1 desc |
165 | # 1 desc |
157 | # 2 timeout |
166 | # 2 timeout |
158 | # 3 rb |
167 | # 3 rb |
159 | # 4 wb |
168 | # 4 wb # unused |
160 | # 5 rw |
169 | # 5 rw |
161 | # 6 ww |
170 | # 6 ww |
162 | |
171 | |
163 | sub TIEHANDLE { |
172 | sub TIEHANDLE { |
164 | my $class = shift; |
173 | my $class = shift; |