Class | Ramaze::Reloader::WatchInotify
In: | lib/ramaze/reloader/watch_inotify.rb
Parent: | Object

TODO:

      * There seems to be a problem somewhere that I couldn't identify yet, a
        file has to be modified twice initially to make it show up as
        modified here, subsequent changes work just fine.
        The only workaround I could find right now would be to read/write
        every single file, but that would be unexpected, irresponsible, and
        error-prone.

NOTE:

      * I have changed from using a Mutex to using a Queue, which uses a
        Mutex internally.

### Methods

call changed_files close new remove_watch start_watcher watch watcher_cycle

### Constants

POLL_INTERVAL | = | 2
NOTIFY_MASK | = | RInotify::MODIFY | RInotify::IN_ONESHOT

### Public Class methods

new()

### Public Instance methods

call(cooldown) {|| ...}
changed_files() {|file| ...}

NOTE:

      We have to add the changed file again after we got a notification, I
      have no idea why, but using IN_ONESHOT should make sure that there is
      no memory leak in the C level even if we add a file again.
      There is a memory leak however in the watch_descriptors hash, since
      rinotify won't synchronize the contents properly and will only add to
      the hash, so we have to clean up ourselves.

close()
remove_watch(file)

FIXME:

      Seems like this won't work due to some bug in the rinotify library.
      Would be cool if someone could make a FFI version.

start_watcher()

TODO: define a finalizer to cleanup? — reloader never calls close

watch(file)
watcher_cycle()

Not much work here, we just have to empty the event queue and push the descriptors for reloading on next request.

[Validate]