(file) Return to Thread.cpp CVS log (file) (dir) Up to [Pegasus] / pegasus / src / Pegasus / Common

Diff for /pegasus/src/Pegasus/Common/Thread.cpp between version 1.19 and 1.20

version 1.19, 2002/06/07 15:17:13 version 1.20, 2002/06/07 20:52:13
Line 115 
Line 115 
  
 #endif #endif
  
   DQueue<ThreadPool> ThreadPool::_pools(true);
   
   
   void ThreadPool::kill_idle_threads(void)
   {
      static struct timeval now, last = {0, 0};
   
      pegasus_gettimeofday(&now);
      if(now.tv_sec - last.tv_sec > 5)
      {
         _pools.lock();
         ThreadPool *p = _pools.next(0);
         while(p != 0)
         {
            try
            {
               p->kill_dead_threads();
            }
            catch(...)
            {
            }
            p = _pools.next(p);
         }
         _pools.unlock();
         pegasus_gettimeofday(&last);
      }
   }
   
   
 ThreadPool::ThreadPool(Sint16 initial_size, ThreadPool::ThreadPool(Sint16 initial_size,
                        const Sint8 *key,                        const Sint8 *key,
                        Sint16 min,                        Sint16 min,
Line 146 
Line 175 
    {    {
       _link_pool(_init_thread());       _link_pool(_init_thread());
    }    }
      _pools.insert_last(this);
   
 } }
  
  
Line 153 
Line 184 
 ThreadPool::~ThreadPool(void) ThreadPool::~ThreadPool(void)
 { {
  
      _pools.remove(this);
    _dying++;    _dying++;
    Thread *th = 0;    Thread *th = 0;
    th = _pool.remove_first();    th = _pool.remove_first();
Line 198 
Line 230 
       delete th;       delete th;
       th = _dead.remove_first();       th = _dead.remove_first();
    }    }
   
 } }
  
 // make this static to the class // make this static to the class
Line 274 
Line 307 
          throw NullPointer();          throw NullPointer();
       }       }
       gettimeofday(deadlock_timer, NULL);       gettimeofday(deadlock_timer, NULL);
         try
         {
       _work(parm);       _work(parm);
         }
         catch(...)
         {
            gettimeofday(deadlock_timer, NULL);
         }
         gettimeofday(deadlock_timer, NULL);
       if( blocking_sem != 0 )       if( blocking_sem != 0 )
          blocking_sem->signal();          blocking_sem->signal();
  
Line 398 
Line 438 
          }          }
       }       }
       delete dead;       delete dead;
         pegasus_sleep(1);
    }    }
  
    DQueue<Thread> * map[2] =    DQueue<Thread> * map[2] =
Line 410 
Line 451 
    int i = 0;    int i = 0;
    AtomicInt needed(0);    AtomicInt needed(0);
  
    for( q = map[i] ; i < 2; i++, q = map[i])     for( q = map[i] ; i < 2; i++, q = map[i], pegasus_sleep(1))
    {    {
       if(q->count() > 0 )       if(q->count() > 0 )
       {       {
Line 507 
Line 548 
                }                }
             }             }
             th = q->next(th);             th = q->next(th);
               pegasus_sleep(1);
          }          }
          q->unlock();          q->unlock();
          while (needed.value() > 0)          while (needed.value() > 0)
          {          {
             _link_pool(_init_thread());             _link_pool(_init_thread());
             needed--;             needed--;
               pegasus_sleep(0);
          }          }
       }       }
    }    }


Legend:
Removed from v.1.19  
changed lines
  Added in v.1.20

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2