http://qs321.pair.com?node_id=738893

Eyck has asked for the wisdom of the Perl Monks concerning the following question:

I'm watching for events in the directory, and I seem to be missing something fundamental (and/or trivial). Here's how I do it:
while ($keepOnWatching) { $inotify->watch($watchpoint,IN_ALL_EVENTS); @events=$inotify->read;# sleep, and wake when events arrive # undef $inotify processEvents(@events); }
this works nice, except that it misses events that arrive while im in 'processEvents', the obvious fix would be this:
$inotify->watch($watchpoint,IN_ALL_EVENTS); while ($keepOnWatching) { @events=$inotify->read;# sleep, and wake when events arrive processEvents(@events); }
but this will use 100% cpu in 'processEvents', because some of the actions in processEvents get caught by inotify watch. I can't seem to figure out a way out of this conundrum, this looks to be similar to the problem speakerphone solves, I just don't know how to approach this.