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

version» Context lines:

pike.git/lib/modules/Filesystem.pmod/Monitor.pmod/basic.pike:196:       //! Register the @[Monitor] with the monitoring system.    //!    //! @param initial    //! Indicates that the @[Monitor] is newly created.    protected void register_path(int|void initial)    {    if (initial) {    // We need to be polled...    MON_WERR("Registering %O for polling.\n", path); +  mixed key = monitor_mutex->lock();    monitor_queue->push(this);    }    }       //! Unregister the @[Monitor] from the monitoring system.    //!    //! @param dying    //! Indicates that the @[Monitor] is being destructed.    protected void unregister_path(int|void dying)    {    if (dying) {    // We are going away permanently, so remove ourselves from    // from the monitor_queue.    MON_WERR("Unregistering %O from polling.\n", path); -  +  mixed key = monitor_mutex->lock();    monitor_queue->remove(this);    }    }       int `<(mixed m) { return next_poll < m; }    int `>(mixed m) { return next_poll > m; }       void create()    {    Element::create(this);
pike.git/lib/modules/Filesystem.pmod/Monitor.pmod/basic.pike:1072:    instance->rm_watch(wd);    };    if (err) {    MON_WERR("### Failed: %s\n", describe_backtrace(err));    }    }    wd = -1;    if (!dying && !(flags & MF_AUTO)) {    // We now need to be polled...    MON_WERR("Registering for polling.\n"); +  mixed key = monitor_mutex->lock();    monitor_queue->push(this); -  +  key = UNDEFINED;    }    }    ::unregister_path(dying);    }   }      constant DefaultMonitor = InotifyMonitor;      #else   
pike.git/lib/modules/Filesystem.pmod/Monitor.pmod/basic.pike:1122:   //! All filesystems are handled as if case-sensitive. This should   //! not be a problem for case-insensitive filesystems as long as   //! case is maintained.   protected mapping(string:Monitor) monitors = ([]);      //! Heap containing active @[Monitor]s that need polling.   //!   //! The heap is sorted on @[Monitor()->next_poll].   protected ADT.Heap monitor_queue = ADT.Heap();    + //! Mutex controlling access to @[monitor_queue]. + protected Thread.Mutex monitor_mutex = Thread.Mutex(); +    //! Create a new monitor.   //!   //! @param max_dir_check_interval   //! Override of @[default_max_dir_check_interval].   //!   //! @param file_interval_factor   //! Override of @[default_file_interval_factor].   //!   //! @param stable_time   //! Override of @[default_stable_time].
pike.git/lib/modules/Filesystem.pmod/Monitor.pmod/basic.pike:1163:    destruct (m);   }      //! Clear the set of monitored files and directories.   //!   //! @note   //! Due to circular datastructures, it's recomended   //! to call this function prior to discarding the object.   void clear()   { +  mixed key = monitor_mutex->lock();    monitors = ([]);    monitor_queue = ADT.Heap();   #if HAVE_EVENTSTREAM    eventstream = 0;   #elseif HAVE_INOTIFY    instance = 0;   #endif   }      //! Calculate a suitable time for the next poll of this monitor.
pike.git/lib/modules/Filesystem.pmod/Monitor.pmod/basic.pike:1194:    m->update(st);   }      //! Release a single @[Monitor] from monitoring.   //!   //! @seealso   //! @[release()]   protected void release_monitor(Monitor m)   {    if (m->accellerated) return; +  mixed key = monitor_mutex->lock();    monitor_queue->remove(m);   }      //! Update the position in the @[monitor_queue] for the monitor @[m]   //! to account for an updated next_poll value.   protected void adjust_monitor(Monitor m)   {    if (m->accellerated) return; -  +  mixed key = monitor_mutex->lock();    monitor_queue->adjust(m);   }      //! Create a new @[Monitor] for a @[path].   //!   //! This function is called by @[monitor()] to create a new @[Monitor]   //! object.   //!   //! The default implementation just calls @[DefaultMonitor] with the   //! same arguments.
pike.git/lib/modules/Filesystem.pmod/Monitor.pmod/basic.pike:1556:   //! @param backend   //! Backend to use. @expr{0@} (zero) for the default backend.   void set_backend(Pike.Backend|void backend)   {    int was_nonblocking = !!co_id;    set_blocking();    this::backend = backend;   #if HAVE_EVENTSTREAM   #if 0 /* FIXME: The following does NOT work properly. */    if (eventstream && backend) { +  mixed key = monitor_mutex->lock();    foreach(monitors; string path; Monitor m) {    if (m->accellerated) {    m->accellerated = 0;    monitor_queue->push(m);    }    } -  +  key = UNDEFINED;    }   #endif   #elif HAVE_INOTIFY    if (instance) {    instance->set_backend(backend || Pike.DefaultBackend);    }   #endif    if (was_nonblocking) {    set_nonblocking();    }