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

version» Context lines:

pike.git/lib/modules/Filesystem.pmod/Monitor.pmod/basic.pike:33: Inside #if HAVE_EVENTSTREAM
   array eventstream_paths = ({});       // This function is called when the FSEvents EventStream detects a change in one of the monitored directories.    void eventstream_callback(string path, int flags, int event_id)    {    if(path[-1] == '/') path = path[0..<1];    if(monitors[path])    {    monitors[path]->check(0);    } -  else check(0); +  else check_all();    }   #elseif HAVE_INOTIFY       object instance;    object file;       void inotify_parse(mixed id, string data)    {    while (sizeof(data)) {    array a;
pike.git/lib/modules/Filesystem.pmod/Monitor.pmod/basic.pike:61:    werror("Could not parse inotify event: %s\n", describe_error(err));    return;    }    string path;    path = a[3];    if(path && monitors[path])    {    monitors[path]->check(0);    }    else -  { check(0); // no need to look at the others if we're going to do a full scan. +  { +  // No need to look at the other entries if we're going to do +  // a full scan. +  check_all();    return;    }       data = data[a[4]..];    }    }      #endif /* HAVE_EVENTSTREAM */      //! The default maximum number of seconds between checks of directories
pike.git/lib/modules/Filesystem.pmod/Monitor.pmod/basic.pike:1060:   //! detected changes in recursive mode.   //!   //! @seealso   //! @[check()], @[data_changed()], @[attr_changed()], @[file_created()],   //! @[file_deleted()], @[stable_data_change()]   protected int(0..1) check_monitor(Monitor m, MonitorFlags|void flags)   {    return m->check(flags);   }    + //! Check all monitors for changes. + //! + //! @param ret_stats + //! Optional mapping that will be filled with statistics (see below). + //! + //! All monitored paths will be checked for changes. + //! + //! @note + //! You typically don't want to call this function, but instead + //! @[check()]. + //! + //! @note + //! Any callbacks will be called from the same thread as the one + //! calling @[check()]. + //! + //! @seealso + //! @[check()], @[monitor()] + void check_all(mapping(string:int)|void ret_stats) + { +  int cnt; +  int scanned_cnt; +  foreach(monitors; string path; Monitor m) { +  scanned_cnt++; +  cnt += check_monitor(m); +  } +  if (ret_stats) { +  ret_stats->num_monitors = sizeof(monitors); +  ret_stats->scanned_monitors = scanned_cnt; +  ret_stats->updated_monitors = cnt; +  ret_stats->idle_time = 0; +  } + } +    //! Check for changes.   //!   //! @param max_wait   //! Maximum time in seconds to wait for changes. @expr{-1@}   //! for infinite wait.   //!   //! @param max_cnt   //! Maximum number of paths to check in this call. @expr{0@}   //! (zero) for unlimited.   //!
pike.git/lib/modules/Filesystem.pmod/Monitor.pmod/basic.pike:1099:   //! The number of monitors that were updated during the call.   //! @member int "idle_time"   //! The number of seconds that the call slept.   //! @endmapping   //!   //! @note   //! Any callbacks will be called from the same thread as the one   //! calling @[check()].   //!   //! @seealso - //! @[monitor()] + //! @[check_all()], @[monitor()]   int check(int|void max_wait, int|void max_cnt,    mapping(string:int)|void ret_stats)   {    int scan_cnt = max_cnt;    int scan_wait = max_wait;    while(1) {    int ret = max_dir_check_interval;    int cnt;    int t = time();    if (sizeof(monitors)) {