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

version» Context lines:

pike.git/lib/modules/Filesystem.pmod/Monitor.pmod/basic.pike:776:   #if constant(System.Inotify)   #define HAVE_INOTIFY 1   #endif      #if HAVE_EVENTSTREAM   protected System.FSEvents.EventStream eventstream;   protected array(string) eventstream_paths = ({});      //! This function is called when the FSEvents EventStream detects a change   //! in one of the monitored directories. - protected void eventstream_callback(string path, int flags, int event_id) + protected void low_eventstream_callback(string path, int flags, int event_id)   {    MON_WERR("eventstream_callback(%O, 0x%08x, %O)\n", path, flags, event_id);    if(path[-1] == '/') path = path[0..<1];    MON_WERR("Normalized path: %O\n", path);       int monitor_flags;    if (flags & System.FSEvents.kFSEventStreamEventFlagMustScanSubDirs)    monitor_flags |= MF_RECURSE;       int found;
pike.git/lib/modules/Filesystem.pmod/Monitor.pmod/basic.pike:803: Inside #if HAVE_EVENTSTREAM
   found = 1;    break;    }    checkpath = dirname (checkpath);    }       if (!found)    MON_WERR("No monitor found for path %O.\n", path);   }    + 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); + } +    //! FSEvents EventStream-accellerated @[Monitor].   protected class EventStreamMonitor   {    inherit Monitor;       int(0..1) accellerated;       protected void do_stable_check()    {    check();
pike.git/lib/modules/Filesystem.pmod/Monitor.pmod/basic.pike:843: Inside #if HAVE_EVENTSTREAM
   }       protected void attr_changed(string path, Stdio.Stat st)    {    (backend || Pike.DefaultBackend)->call_out(do_stable_check, 0);    ::attr_changed(path, st);    }       protected void register_path(int|void initial)    { -  if (backend) { -  // CFRunLoop only works with the primary backend. -  ::register_path(initial); -  return; -  } +    #ifndef INHIBIT_EVENTSTREAM_MONITOR    if (!initial) return;       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) {    // 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
pike.git/lib/modules/Filesystem.pmod/Monitor.pmod/basic.pike:888: Inside #if HAVE_EVENTSTREAM
   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);    accellerated = 1;    monitors[path] = this; -  check(); +  (backend || Pike.DefaultBackend)->call_out(check, 0);    return;    }    }       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();    };       if (!err) {    monitors[path] = this; -  check(); +  (backend || Pike.DefaultBackend)->call_out(check, 0);    return;    }       werror (describe_backtrace (err));    // Note: falling through to ::register_path() below.      #endif /* !INHIBIT_EVENTSTREAM_MONITOR */    // NB: Eventstream doesn't notify on the monitored path;    // only on its contents.    ::register_path(initial);