pike.git / lib / modules / Filesystem.pmod / Monitor.pmod / basic.pike

version» Context lines:

pike.git/lib/modules/Filesystem.pmod/Monitor.pmod/basic.pike:809: Inside #if HAVE_EVENTSTREAM
  }      protected void eventstream_callback(string path, int flags, int event_id)   {    if (backend)    backend->call_out(low_eventstream_callback, 0, path, flags, event_id);    else    low_eventstream_callback(path, flags, event_id);   }    - protected void start_accellerator() + protected void start_accelerator()   {    // Make sure that the main backend is in CF-mode.    Pike.DefaultBackend.enable_core_foundation(1);       MON_WERR("Creating event stream.\n");   #if constant (System.FSEvents.kFSEventStreamCreateFlagFileEvents)    int flags = System.FSEvents.kFSEventStreamCreateFlagFileEvents;   #else    int flags = System.FSEvents.kFSEventStreamCreateFlagNone;   #endif       eventstream =    System.FSEvents.EventStream(({}), 1.0,    System.FSEvents.kFSEventStreamEventIdSinceNow,    flags);    eventstream->callback_func = eventstream_callback;   }    - //! FSEvents EventStream-accellerated @[Monitor]. + //! FSEvents EventStream-accelerated @[Monitor].   protected class EventStreamMonitor   {    inherit Monitor;       protected void register_path(int|void initial)    {   #ifndef INHIBIT_EVENTSTREAM_MONITOR    if (initial) {    if (Pike.DefaultBackend.executing_thread() != Thread.this_thread()) {    // eventstream stuff (especially start()) must be called from    // the backend thread, otherwise events will be fired in    // CFRunLoop contexts where noone listens.    call_out(register_path, 0, initial);    return;    }       // We're now in the main backend.       if (!eventstream) { -  start_accellerator(); +  start_accelerator();    }       string found;    foreach(eventstream_paths;;string p) {    if((path == p) || has_prefix(path, p + "/")) {    MON_WERR("Path %O already monitored via path %O.\n", path, p);    found = p;    break;    }    }    if (found) { -  MON_WERR("Path %O is accellerated via %O.\n", path, found); +  MON_WERR("Path %O is accelerated via %O.\n", path, found);    } else {    // NB: Eventstream doesn't notify on the monitored path;    // only on its contents.    mixed err = catch {    MON_WERR("Adding %O to the set of monitored paths.\n", path);    eventstream_paths += ({path});    if(eventstream->is_started())    eventstream->stop();    eventstream->add_path(path);    eventstream->start();
pike.git/lib/modules/Filesystem.pmod/Monitor.pmod/basic.pike:936:    m->check(0);    };    if (err) {    master()->handle_error(err);    }    } else {    MON_WERR("No monitor found for path %O.\n", path);    }   }    - protected void start_accellerator() + protected void start_accelerator()   {    MON_WERR("Creating Inotify monitor instance.\n");    instance = System.Inotify._Instance();    if (backend) instance->set_backend(backend);    instance->set_event_callback(inotify_event);    if (co_id) {    MON_WERR("Turning on nonblocking mode for Inotify.\n");    instance->set_nonblocking();    }   }    - //! Inotify-accellerated @[Monitor]. + //! Inotify-accelerated @[Monitor].   protected class InotifyMonitor   {    inherit Monitor;       protected int wd = -1;    protected int(0..) out_of_inotify_space;       protected void register_path(int|void initial)    {   #ifndef INHIBIT_INOTIFY_MONITOR    if (wd == -1) {    if (!instance) { -  start_accellerator(); +  start_accelerator();    }       // NB: We need to follow symlinks here.    // Currently we only support changing symlinks and symlinks to directories.    // FIXME: Handle broken symlinks where the target later shows up and    // symlinks to changing files.    Stdio.Stat st = file_stat(path);    mixed err;    if (st && (!(flags & MF_AUTO) || st->isdir)) {    // Note: We only want to add watchers on directories. File
pike.git/lib/modules/Filesystem.pmod/Monitor.pmod/basic.pike:1596:   //! @[set_blocking()], @[check()].   void set_nonblocking(int|void t)   {   #if HAVE_INOTIFY    if (instance) {    instance->set_nonblocking();    }   #endif    if (co_id) return;    // NB: Other stuff than plain files may be used with the monitoring -  // system, so the call_out may be needed even with accellerators. +  // system, so the call_out may be needed even with accelerators.    //    // NB: Also note that Inotify doesn't support monitoring of non-existing    // paths, so it still needs the call_out-loop.    if (undefinedp(t)) {    if (sizeof(monitor_queue)) {    Monitor m = monitor_queue->peek();    t = (m && m->next_poll - time(1)) || max_dir_check_interval;    } else {    t = max_dir_check_interval;    }