Branch: Tag:

2017-06-14

2017-06-14 13:49:54 by Martin Karlgren <marty@roxen.com>

Filesystem.Monitor: Fix EventStreamMonitor to work with other backends.

783: Inside #if HAVE_EVENTSTREAM
     //! 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];
810: Inside #if HAVE_EVENTSTREAM
   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   {
850: Inside #if HAVE_EVENTSTREAM
      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;   
866: Inside #if HAVE_EVENTSTREAM and #if undefined(INHIBIT_EVENTSTREAM_MONITOR)
   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);
895: Inside #if HAVE_EVENTSTREAM
   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;    }    }
911: Inside #if HAVE_EVENTSTREAM
      if (!err) {    monitors[path] = this; -  check(); +  (backend || Pike.DefaultBackend)->call_out(check, 0);    return;    }