AnyEvent-Filesys-Notify
view release on metacpan or search on metacpan
lib/AnyEvent/Filesys/Notify.pm view on Meta::CPAN
backend => 'KQueue',
backend => '+My::Filesys::Notify::Role::Backend',
Force the use of the specified backend. The backend is assumed to have the
C<AnyEvent::Filesys::Notify::Role> prefix, but you can force a fully qualified
name by prefixing it with a plus. Optional.
=item no_external
no_external => 1,
This is retained for backward compatibility. Using C<backend => 'Fallback'>
is preferred. Force the use of the L</Fallback> watcher implementation. This is
not encouraged as the L</Fallback> implement is very inefficient, but it does
not require either L<Linux::INotify2> nor L<Mac::FSEvents>. Optional.
=item parse_events
parse_events => 1,
In backends that support it (currently INotify2), parse the events instead of
rescanning file system for changed C<stat()> information. Note, that this might
cause slight changes in behavior. In particular, the Inotify2 backend will
generate an additional 'modified' event when a file changes (once when opened
for write, and once when modified).
=item skip_subdirs
skip_subdirs => 1,
Skips subdirectories and anything in them while building a list of files/dirs
to watch. Optional.
=back
=head1 WATCHER IMPLEMENTATIONS
=head2 INotify2 (Linux)
Uses L<Linux::INotify2> to monitor directories. Sets up an C<AnyEvent-E<gt>io>
watcher to monitor the C<$inotify-E<gt>fileno> filehandle.
=head2 FSEvents (Mac)
Uses L<Mac::FSEvents> to monitor directories. Sets up an C<AnyEvent-E<gt>io>
watcher to monitor the C<$fsevent-E<gt>watch> filehandle.
=head2 KQueue (BSD/Mac)
Uses L<IO::KQueue> to monitor directories. Sets up an C<AnyEvent-E<gt>io>
watcher to monitor the C<IO::KQueue> object.
B<WARNING> - L<IO::KQueue> and the C<kqueue()> system call require an open
filehandle for every directory and file that is being watched. This makes
it impossible to watch large directory structures (and inefficient to watch
moderately sized directories). The use of the KQueue backend is discouraged.
=head2 Fallback
A simple scan of the watched directories at regular intervals. Sets up an
C<AnyEvent-E<gt>timer> watcher which is executed every C<interval> seconds
(or fractions thereof). C<interval> can be specified in the constructor to
L<AnyEvent::Filesys::Notify> and defaults to 2.0 seconds.
This is a very inefficient implementation. Use one of the others if possible.
=head1 Why Another Module For File System Notifications
At the time of writing there were several very nice modules that accomplish
the task of watching files or directories and providing notifications about
changes. Two of which offer a unified interface that work on any system:
L<Filesys::Notify::Simple> and L<File::ChangeNotify>.
L<AnyEvent::Filesys::Notify> exists because I need a way to simply tie the
functionality those modules provide into an event framework. Neither of the
existing modules seem to work with well with an event loop.
L<Filesys::Notify::Simple> does not supply a non-blocking interface and
L<File::ChangeNotify> requires you to poll an method for new events. You could
fork off a process to run L<Filesys::Notify::Simple> and use an event handler
to watch for notices from that child, or setup a timer to check
L<File::ChangeNotify> at regular intervals, but both of those approaches seem
inefficient or overly complex. Particularly, since the underlying watcher
implementations (L<Mac::FSEvents> and L<Linux::INotify2>) provide a filehandle
that you can use and IO event to watch.
This is not slight against the authors of those modules. Both are well
respected, are certainly finer coders than I am, and built modules which
are perfect for many situations. If one of their modules will work for you
by all means use it, but if you are already using an event loop, this
module may fit the bill.
=head1 SEE ALSO
Modules used to implement this module L<AnyEvent>, L<Mac::FSEvents>,
L<Linux::INotify2>, L<Moose>.
Alternatives to this module L<Filesys::Notify::Simple>, L<File::ChangeNotify>.
=head1 AUTHOR
Mark Grimes, E<lt>mgrimes@cpan.orgE<gt>
=head1 CONTRIBUTORS
=over 4
=item *
Gasol Wu E<lt>gasol.wu@gmail.comE<gt> who contributed the BSD support for IO::KQueue
=item *
Dave Hayes E<lt>dave@jetcafe.orgE<gt>
=item *
Carsten Wolff E<lt>carsten@wolffcarsten.deE<gt>
=item *
Ettore Di Giacinto (@mudler)
=item *
Martin Barth (@ufobat)
=back
=head1 SOURCE
Source repository is at L<https://github.com/mvgrimes/AnyEvent-Filesys-Notify>.
=head1 BUGS
Please report any bugs or feature requests on the bugtracker website L<http://github.com/mvgrimes/AnyEvent-Filesys-Notify/issues>
When submitting a bug or request, please include a test-file or a
patch to an existing test-file that illustrates the bug or desired
feature.
( run in 2.228 seconds using v1.01-cache-2.11-cpan-cdf2f3d4e48 )