Roxen.git / server / base_server / roxen.pike

version» Context lines:

Roxen.git/server/base_server/roxen.pike:1:   // This file is part of Roxen WebServer.   // Copyright © 1996 - 2004, Roxen IS.   //   // The Roxen WebServer main program.   //   // Per Hedbor, Henrik Grubbström, Pontus Hagland, David Hedbor and others.   // ABS and suicide systems contributed freely by Francesco Chemolli    - constant cvs_version="$Id: roxen.pike,v 1.882 2004/09/28 11:57:26 mast Exp $"; + constant cvs_version="$Id: roxen.pike,v 1.883 2004/10/11 14:40:26 wellhard Exp $";      //! @appears roxen   //!   //! The Roxen WebServer main program.      // The argument cache. Used by the image cache.   ArgCache argcache;      // Some headerfiles   #define IN_ROXEN
Roxen.git/server/base_server/roxen.pike:950: Inside #if defined(THREADS)
  static Thread.Queue bg_queue = Thread.Queue();   static int bg_process_running;      // Use a time buffer to strike a balance if the server is busy and   // always have at least one busy thread: The maximum waiting time in   // that case is somewhere between bg_time_buffer_min and   // bg_time_buffer_max. If there are only short periods of time between   // the queue runs, the max waiting time will shrink towards the   // minimum.   static constant bg_time_buffer_max = 30; - static constant bg_time_buffer_min = 0.5; + static constant bg_time_buffer_min = 0;   static int bg_last_busy = 0;      static void bg_process_queue()   {    if (bg_process_running) return;    // Relying on the interpreter lock here.    bg_process_running = 1;       int maxbeats =    min (time() - bg_last_busy, bg_time_buffer_max) * (int) (1 / 0.04);
Roxen.git/server/base_server/roxen.pike:978: Inside #if defined(THREADS)
   if (busy_threads > 1) {    for (maxbeats = max (maxbeats, (int) (bg_time_buffer_min / 0.04));    busy_threads > 1 && maxbeats > 0;    maxbeats--)    // Pike implementation note: If 0.02 or smaller, we'll busy wait here.    sleep (0.04);    bg_last_busy = time();    }      #ifdef DEBUG_BACKGROUND_RUN -  report_debug ("background_run run %s (%s)\n", +  report_debug ("background_run run %s (%s) [%d jobs left in queue]\n",    functionp (task[0]) ?    sprintf ("%s: %s", Function.defined (task[0]),    master()->describe_function (task[0])) :    programp (task[0]) ?    sprintf ("%s: %s", Program.defined (task[0]),    master()->describe_program (task[0])) :    sprintf ("%O", task[0]),    map (task[1], lambda (mixed arg) -  {return sprintf ("%O", arg);}) * ", "); +  {return sprintf ("%O", arg);}) * ", ", +  bg_queue->size()); +  float task_time = gauge {   #endif    if (task[0]) // Ignore things that have become destructed.    // Note: BackgroundProcess.repeat assumes that there are    // exactly two refs to task[0] during the call below.    task[0] (@task[1]); -  + #ifdef DEBUG_BACKGROUND_RUN +  }; +  report_debug ("background_run done, took %f sec\n", task_time); + #endif       if (busy_threads > 1) bg_last_busy = time();    }    }) {    bg_process_running = 0;    handle (bg_process_queue);    throw (err);    }    bg_process_running = 0;   }
Roxen.git/server/base_server/roxen.pike:1021:   //! The function @[func] will be enqueued after approximately @[delay]   //! seconds, to be called with the rest of the arguments as its   //! arguments.   //!   //! The function might be run in the backend thread, so it should   //! never run for a considerable time. Instead do another call to   //! @[background_run] to queue it up again after some work has been   //! done, or use @[BackgroundProcess].   {   #ifdef DEBUG_BACKGROUND_RUN -  report_debug ("background_run enqueue %s (%s)\n", +  report_debug ("background_run enqueue %s (%s) [%d jobs in queue]\n",    functionp (func) ?    sprintf ("%s: %s", Function.defined (func),    master()->describe_function (func)) :    programp (func) ?    sprintf ("%s: %s", Program.defined (func),    master()->describe_program (func)) :    sprintf ("%O", func),    map (args, lambda (mixed arg) -  {return sprintf ("%O", arg);}) * ", "); +  {return sprintf ("%O", arg);}) * ", ", +  bg_queue->size());   #endif      #ifdef THREADS    if (!hold_wakeup_cond)    // stop_handler_threads is running; ignore more work.    return;       function enqueue = lambda()    {    bg_queue->write (({func, args}));