Пример #1
0
 /**
  * {@inheritdoc}
  *
  * @throws RuntimeException If event queue overflowed
  */
 public function getEvents()
 {
     $inotifyEvents = $this->readEvents();
     $inotifyEvents = is_array($inotifyEvents) ? $inotifyEvents : array();
     $last = end($inotifyEvents);
     if (IN_Q_OVERFLOW === $last['mask']) {
         throw new RuntimeException('Event queue overflowed. Either read events more frequently or increase the limit for queues. The limit can be changed in /proc/sys/fs/inotify/max_queued_events');
     }
     foreach ($inotifyEvents as $event) {
         foreach ($this->bag->get($event['wd']) as $watched) {
             $watched->setEvent($event['mask'], $event['name']);
         }
     }
     $events = array();
     foreach ($this->checkers as $meta) {
         $tracked = $meta['tracked'];
         $watched = $meta['checker'];
         foreach ($watched->getChangeset() as $change) {
             $events[] = new FilesystemEvent($tracked, $change['resource'], $change['event']);
         }
     }
     return $events;
 }
Пример #2
0
 /**
  * Unwatch resource
  *
  * @param int $id Watch descriptor
  */
 protected function unwatch($id)
 {
     @inotify_rm_watch($this->bag->getInotify(), $id);
 }