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

version» Context lines:

pike.git/lib/modules/Filesystem.pmod/Monitor.pmod/basic.pike:1:   //   // Basic filesystem monitor.   // - // $Id: basic.pike,v 1.1 2009/07/13 08:55:30 grubba Exp $ + // $Id: basic.pike,v 1.2 2009/07/13 09:08:19 grubba Exp $   //   // 2009-07-09 Henrik Grubbström   //    -  + //! Basic filesystem monitor. + //! + //! This module is intended to be used for incremental scanning of + //! a filesystem. +    //! The default maximum number of seconds between checks of directories   //! in seconds.   //!   //! This value is multiplied with @[default_file_interval_factor] to   //! get the corresponding default maximum number of seconds for files.   //!   //! The value can be changed by calling @[create()].   //!   //! The value can be overridden for individual files or directories   //! by calling @[monitor()].
pike.git/lib/modules/Filesystem.pmod/Monitor.pmod/basic.pike:431:    m <= t) {    cnt += check_monitor(m);    }    if (cnt || !max_wait) return;    if (max_wait > 0) max_wait--;    sleep(1);    }   }      //! Backend to use. + //! + //! If @expr{0@} (zero) - use the default backend.   protected Pike.Backend backend;      //! Call-out identifier for @[backend_check()] if in   //! nonblocking mode.   //!   //! @seealso   //! @[set_nonblocking()], @[set_blocking()]   protected mixed co_id;      //! Change backend.
pike.git/lib/modules/Filesystem.pmod/Monitor.pmod/basic.pike:454:   void set_backend(Pike.Backend|void backend)   {    int was_nonblocking = !!co_id;    set_blocking();    this_program::backend = backend;    if (was_nonblocking) {    set_nonblocking();    }   }    + //! Turn off nonblocking mode. + //! + //! @seealso + //! @[set_nonblocking()]   void set_blocking()   {    if (co_id) {    if (backend) backend->remove_call_out(co_id);    else remove_call_out(co_id);    co_id = 0;    }   }    -  + //! Backend check callback function. + //! + //! This function is intended to be called from a backend, + //! and performs a @[check()] followed by rescheduling + //! itself via a call to @[set_nonblocking()]. + //! + //! @seealso + //! @[check()], @[set_nonblocking()]   protected void backend_check()   {    co_id = 0;    mixed err = catch {    check(0);    };    set_nonblocking();    if (err) throw(err);   }    -  + //! Turn on nonblocking mode. + //! + //! Register suitable callbacks with the backend to automatically + //! call @[check()]. + //! + //! @[check()] and thus all the callbacks will be called from the + //! backend thread. + //! + //! @seealso + //! @[set_blocking()], @[check()].   void set_nonblocking()   {    if (co_id) return;    Monitor m = monitor_queue->peek();    int t = (m && m->next_poll - time(1)) || max_dir_check_interval;    if (t > max_dir_check_interval) t = max_dir_check_interval;    if (backend) co_id = backend->call_out(backend_check, t);    else co_id = call_out(backend_check, t);   }