pike.git / lib / modules / Search.pmod / Utils.pmod

version» Context lines:

pike.git/lib/modules/Search.pmod/Utils.pmod:1:   // This file is part of Roxen Search   // Copyright © 2001 - 2009, Roxen IS. All rights reserved.   // - // $Id: Utils.pmod,v 1.49 2010/04/28 12:09:39 noring Exp $ + // $Id: Utils.pmod,v 1.50 2010/06/03 11:52:35 noring Exp $      #if !constant(report_error)   #define report_error werror   #define report_debug werror   #define report_warning werror   #endif      #ifdef SEARCH_DEBUG   # define WERR(X) report_debug("search: "+(X)+"\n");   #else
pike.git/lib/modules/Search.pmod/Utils.pmod:446:   }      class Scheduler {       private int next_run;    private mapping(int:int) entry_queue = ([]);    private mapping(int:int) crawl_queue = ([]);    private mapping(int:int) compact_queue = ([]);    private array(int) priority_queue = ({});    private mapping db_profiles; -  private object schedule_process; +  private mixed schedule_run;       void create(mapping _db_profiles) {    db_profiles = _db_profiles;    schedule();    }       void check_priority_queue(int profile)    {    if (!has_value(priority_queue, profile))    priority_queue += ({ profile });
pike.git/lib/modules/Search.pmod/Utils.pmod:511:    if(!sizeof(crawl_queue) && !sizeof(compact_queue) && !sizeof(entry_queue))    return;    next_run = max( min( @values(crawl_queue) + values(compact_queue) +    values(entry_queue) ),    time() + 10 );    reschedule();    }      #if constant (roxen)    private void reschedule() { -  if( schedule_process ) -  schedule_process->stop(); +     WERR("Scheduler runs next event in "+(next_run-time())+" seconds."); -  // We use BackgroundProcess since there is no support for unscheduling -  // tasks created with background_run. -  schedule_process = -  roxen.BackgroundProcess(next_run-time(), do_scheduled_stuff); +  remove_call_out(schedule_run); +  schedule_run = roxen.background_run(next_run-time(), do_scheduled_stuff);    }       void unschedule() { -  if( schedule_process ) -  schedule_process->stop(); +  remove_call_out(schedule_run); +  schedule_run = 0;    }          private void do_scheduled_stuff() { -  if( schedule_process ) -  schedule_process->stop(); +  remove_call_out(schedule_run); +  schedule_run = 0;    WERR("Running scheduler event.");       foreach(indices(db_profiles), int id) {    if (db_profiles[id]->is_running()) {    WERR("Postponing crawl start, profile "+id+" still running.");    schedule(1);    return;    }    }