(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.58 and 1.59

version 1.58, 2003/10/23 19:30:23 version 1.59, 2003/10/30 00:22:39
Line 27 
Line 27 
 // //
 // Modified By: Rudy Schuet (rudy.schuet@compaq.com) 11/12/01 // Modified By: Rudy Schuet (rudy.schuet@compaq.com) 11/12/01
 //              added nsk platform support //              added nsk platform support
   //              Roger Kumpf, Hewlett-Packard Company (roger_kumpf@hp.com)
 // //
 //%///////////////////////////////////////////////////////////////////////////// //%/////////////////////////////////////////////////////////////////////////////
  
Line 601 
Line 602 
          {          {
             _work(parm);             _work(parm);
          }          }
            catch(Exception & e)
            {
               PEG_TRACE_STRING(TRC_DISCARDED_DATA, Tracer::LEVEL2,
                  String("Exception from _work in ThreadPool::_loop: ") +
                     e.getMessage());
               PEG_METHOD_EXIT();
               return((PEGASUS_THREAD_RETURN)0);
            }
          catch(...)          catch(...)
          {          {
             Tracer::trace(TRC_DISCARDED_DATA, Tracer::LEVEL2,             Tracer::trace(TRC_DISCARDED_DATA, Tracer::LEVEL2,
Line 657 
Line 666 
    return((PEGASUS_THREAD_RETURN)0);    return((PEGASUS_THREAD_RETURN)0);
 } }
  
 void ThreadPool::allocate_and_awaken(void *parm,  Boolean ThreadPool::allocate_and_awaken(void *parm,
                                      PEGASUS_THREAD_RETURN \                                      PEGASUS_THREAD_RETURN \
                                      (PEGASUS_THREAD_CDECL *work)(void *),                                      (PEGASUS_THREAD_CDECL *work)(void *),
                                      Semaphore *blocking)                                      Semaphore *blocking)
   
    throw(IPCException)    throw(IPCException)
 { {
    PEG_METHOD_ENTER(TRC_THREAD, "ThreadPool::allocate_and_awaken");    PEG_METHOD_ENTER(TRC_THREAD, "ThreadPool::allocate_and_awaken");
Line 676 
Line 684 
       {       {
          Tracer::trace(TRC_DISCARDED_DATA, Tracer::LEVEL2,          Tracer::trace(TRC_DISCARDED_DATA, Tracer::LEVEL2,
           "ThreadPool::allocate_and_awaken: ThreadPool is dying(1).");           "ThreadPool::allocate_and_awaken: ThreadPool is dying(1).");
          return;           // ATTN: Error result has not yet been defined
            return true;
       }       }
       struct timeval now;       struct timeval now;
       struct timeval start;       struct timeval start;
Line 685 
Line 694 
  
       th = _pool.remove_first();       th = _pool.remove_first();
  
       // wait for the right interval and try again        if (th == 0)
       while (th == 0)  
       {       {
          // will throw an IPCException&          // will throw an IPCException&
          _check_deadlock(&start) ;          _check_deadlock(&start) ;
Line 694 
Line 702 
          if(_max_threads == 0 || _current_threads < _max_threads)          if(_max_threads == 0 || _current_threads < _max_threads)
          {          {
             th = _init_thread();             th = _init_thread();
             continue;  
          }          }
          pegasus_yield();        }
          th = _pool.remove_first();  
         if (th == 0)
         {
            return false;
       }       }
  
       // initialize the thread data with the work function and parameters       // initialize the thread data with the work function and parameters
Line 738 
Line 748 
       Tracer::trace(TRC_DISCARDED_DATA, Tracer::LEVEL2,       Tracer::trace(TRC_DISCARDED_DATA, Tracer::LEVEL2,
           "ThreadPool::allocate_and_awaken: Operation Failed.");           "ThreadPool::allocate_and_awaken: Operation Failed.");
       PEG_METHOD_EXIT();       PEG_METHOD_EXIT();
       return;        // ATTN: Error result has not yet been defined
         return true;
    }    }
    PEG_METHOD_EXIT();    PEG_METHOD_EXIT();
      return true;
 } }
  
 // caller is responsible for only calling this routine during slack periods // caller is responsible for only calling this routine during slack periods
Line 923 
Line 935 
  
                bodies++;                bodies++;
                th->dereference_tsd();                th->dereference_tsd();
                _dead.insert_first(th);                 // Putting thread on _dead queue delays availability to others
                  //_dead.insert_first(th);
                sleep_sem->signal();                sleep_sem->signal();
                  th->join();  // Note: Clean up the thread here rather than
                  delete th;   // leave it sitting unused on the _dead queue
                th = 0;                th = 0;
             }             }
             else             else
Line 1025 
Line 1040 
    th->put_tsd("deadlock timer", thread_data::default_delete, sizeof(struct timeval), (void *)dldt);    th->put_tsd("deadlock timer", thread_data::default_delete, sizeof(struct timeval), (void *)dldt);
    // thread will enter _loop(void *) and sleep on sleep_sem until we signal it    // thread will enter _loop(void *) and sleep on sleep_sem until we signal it
  
    th->run();     if (!th->run())
      {
         delete th;
         return 0;
      }
    _current_threads++;    _current_threads++;
    pegasus_yield();    pegasus_yield();
  


Legend:
Removed from v.1.58  
changed lines
  Added in v.1.59

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2