--- IO-AIO/AIO.pm 2005/07/12 11:29:40 1.20 +++ IO-AIO/AIO.pm 2005/07/31 21:21:12 1.25 @@ -24,7 +24,7 @@ # Glib/Gtk2 add_watch Glib::IO IO::AIO::poll_fileno, - in => sub { IO::AIO::poll_cb, 1 }; + in => sub { IO::AIO::poll_cb; 1 }; # Tk Tk::Event::IO->fileevent (IO::AIO::poll_fileno, "", @@ -50,18 +50,22 @@ remaining functionality would have to be implemented using threads anyway. Although the module will work with in the presence of other threads, it is -currently not reentrant, so use appropriate locking yourself. +currently not reentrant, so use appropriate locking yourself, always call +C from within the same thread, or never call C (or other +C functions) recursively. =cut package IO::AIO; +no warnings; + use base 'Exporter'; use Fcntl (); BEGIN { - $VERSION = 0.5; + $VERSION = 1.1; @EXPORT = qw(aio_read aio_write aio_open aio_close aio_stat aio_lstat aio_unlink aio_fsync aio_fdatasync aio_readahead); @@ -83,7 +87,8 @@ perl, which usually delivers "false") as it's sole argument when the given syscall has been executed asynchronously. -All functions that expect a filehandle will also accept a file descriptor. +All functions expecting a filehandle keep a copy of the filehandle +internally until the request has finished. The filenames you pass to these routines I be absolute. The reason for this is that at the time the request is being executed, the current @@ -310,12 +315,16 @@ sub _fd2fh { return undef if $_[0] < 0; - # try to be perl5.6-compatible - local *AIO_FH; - open AIO_FH, "+<&=$_[0]" + # try to generate nice filehandles + my $sym = "IO::AIO::fd#$_[0]"; + local *$sym; + + open *$sym, "+<&$_[0]" # usually under any unix + or open *$sym, "<&$_[0]" # cygwin needs this + or open *$sym, ">&$_[0]" # cygwin needs this or return undef; - *AIO_FH + *$sym } min_parallel 4;