Currently, $watcher->new_events() will block with KQueue watcher.
A new_events() method in File::ChangeNotify::Watcher::KQueue calls $self->_get_events(0), and
in _get_events() it calls $self->_kqueue->kevent() with argument ($timeout || ()). In this
situation, new_events() causes calling _kqueue->kevent() receives undef as first argument
instead of 0.
In IO::KQueue backend, kqueue(0) and kqueue(undef) has different meaning. Former will return
immediately and latter will block until watched event arrives.
So, I think this patch will satisfy the same behavior with other watcher backend.
Hope this helps.
Subject: | patch-KQueue.pm |
--- lib/File/ChangeNotify/Watcher/KQueue.pm.orig 2013-01-26 13:31:16.362045077 +0900
+++ lib/File/ChangeNotify/Watcher/KQueue.pm 2013-01-26 13:42:01.870445472 +0900
@@ -61,7 +61,7 @@
sub _get_events {
my ( $self, $timeout ) = @_;
- my @kevents = $self->_kqueue->kevent( $timeout || () );
+ my @kevents = $self->_kqueue->kevent( $timeout // () );
# Events come in groups, wait for a short period to absorb any extra ones
# that might happen immediately after the ones we've detected.