Monitoring files is a process often needed in applications. The most demanding applications for such a feature are media indexers. They need to know when some multimedia files have changed, appeared, or disappeared so that they re-index them and update their associated metadata. Another usual use case is simply monitoring a configuration file so that changes can be applied dynamically instead of requiring a restart of the application.
There are two ways to monitor files changes: either by directly polling for modifications in the file, or via the operating system providing some APIs to be notified when files are updated. The first solution has the advantage of being more portable. A solution that works on any system simply consists of reading the contents of the file regularly, and checking for any changes in it. Clearly this is a waste of resources because...