… | |
… | |
258 | } |
258 | } |
259 | }; |
259 | }; |
260 | |
260 | |
261 | aio_close $fh, $callback->($status) |
261 | aio_close $fh, $callback->($status) |
262 | Asynchronously close a file and call the callback with the result |
262 | Asynchronously close a file and call the callback with the result |
263 | code. *WARNING:* although accepted, you should not pass in a perl |
263 | code. |
264 | filehandle here, as perl will likely close the file descriptor |
|
|
265 | another time when the filehandle is destroyed. Normally, you can |
|
|
266 | safely call perls "close" or just let filehandles go out of scope. |
|
|
267 | |
264 | |
268 | This is supposed to be a bug in the API, so that might change. It's |
265 | Unlike the other functions operating on files, this function uses |
269 | therefore best to avoid this function. |
266 | the PerlIO layer to close the filehandle. The reason is that the |
|
|
267 | PerlIO API insists on closing the underlying fd itself, no matter |
|
|
268 | what, and doesn't allow modifications to the fd. Unfortunately, it |
|
|
269 | is not clear that you can call PerlIO from different threads |
|
|
270 | (actually, its quite clear that this won't work in some cases), so |
|
|
271 | while it likely works perfectly with simple file handles (such as |
|
|
272 | the ones created by "aio_open") it might fail in interesting ways |
|
|
273 | for others. |
|
|
274 | |
|
|
275 | Having said that, aio_close tries to clean up the filehandle as much |
|
|
276 | as possible before handing it to an io thread, and generally does |
|
|
277 | work. |
270 | |
278 | |
271 | aio_read $fh,$offset,$length, $data,$dataoffset, $callback->($retval) |
279 | aio_read $fh,$offset,$length, $data,$dataoffset, $callback->($retval) |
272 | aio_write $fh,$offset,$length, $data,$dataoffset, $callback->($retval) |
280 | aio_write $fh,$offset,$length, $data,$dataoffset, $callback->($retval) |
273 | Reads or writes $length bytes from the specified $fh and $offset |
281 | Reads or writes $length bytes from the specified $fh and $offset |
274 | into the scalar given by $data and offset $dataoffset and calls the |
282 | into the scalar given by $data and offset $dataoffset and calls the |