FileSystemWatcher implementation

Until now we used to place hacks whenever we needed FileSystemWatcher. Enough.

The brand-new FileSystemWatcher implementation for mono is in CVS now. It relies on 3 classes which provide a Windows-only, a Unix-FAM and a default implementation.

Default implementation

When not running mono in a Windows system, in a Unix system that has libfam+famd around or if MONO_MANAGED_WATCHER environment variable is set, this one is used.

It spawns a thread that takes care of monitoring file changes and does everything in managed code. When unused for a small period of time, the monitoring thread finishes. It works fine if you don't monitor a big subtree full of matching files... It's not able to reliably generate Renamed events.

Unix FAM-based implementation

Used when libfam is successfully loaded at runtime and a connection can be opened. If you use the GNOME desktop, libfam+famd are (probably) already around.

This one also uses a monitor thread, but events on the filesystem are read using the functions provided by the library. FAM itself does more or less the same as the default implementation in managed code, BUT if you use a decent linux distribution, the FAM daemon probably has a patch that enables the use of kernel's dnotify feature. This really speeds things up. However, Renamed events are not supported by FAM as of now.

Windows-only implementation

It's not finished yet. Currently, it uses the default implementation. One day, it will use ReadDirectoryChangesW and, may be, even its asynchronous capabilities.



blog comments powered by Disqus
This is a personal web page. Things said here do not represent the position of my employer.