(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.13 and 1.14

version 1.13, 2002/03/18 15:38:18 version 1.14, 2002/04/06 19:28:00
Line 30 
Line 30 
  
 #include "Thread.h" #include "Thread.h"
 #include <Pegasus/Common/IPC.h> #include <Pegasus/Common/IPC.h>
   #include <Pegasus/Common/Tracer.h>
  
 #if defined(PEGASUS_OS_TYPE_WINDOWS) #if defined(PEGASUS_OS_TYPE_WINDOWS)
 # include "ThreadWindows.cpp" # include "ThreadWindows.cpp"
Line 200 
Line 201 
 // make this static to the class // make this static to the class
 PEGASUS_THREAD_RETURN PEGASUS_THREAD_CDECL ThreadPool::_loop(void *parm) PEGASUS_THREAD_RETURN PEGASUS_THREAD_CDECL ThreadPool::_loop(void *parm)
 { {
      PEG_METHOD_ENTER(TRC_THREAD, "ThreadPool::_loop");
   
    Thread *myself = (Thread *)parm;    Thread *myself = (Thread *)parm;
    if(myself == 0)    if(myself == 0)
      {
         PEG_METHOD_EXIT();
       throw NullPointer();       throw NullPointer();
      }
    ThreadPool *pool = (ThreadPool *)myself->get_parm();    ThreadPool *pool = (ThreadPool *)myself->get_parm();
    if(pool == 0 )    if(pool == 0 )
      {
         PEG_METHOD_EXIT();
       throw NullPointer();       throw NullPointer();
      }
    Semaphore *sleep_sem = 0;    Semaphore *sleep_sem = 0;
    Semaphore *blocking_sem = 0;    Semaphore *blocking_sem = 0;
  
Line 220 
Line 229 
    }    }
    catch(IPCException &)    catch(IPCException &)
    {    {
         PEG_METHOD_EXIT();
       myself->exit_self(0);       myself->exit_self(0);
    }    }
    if(sleep_sem == 0 || deadlock_timer == 0)    if(sleep_sem == 0 || deadlock_timer == 0)
      {
         PEG_METHOD_EXIT();
       throw NullPointer();       throw NullPointer();
      }
  
    while(pool->_dying < 1)    while(pool->_dying < 1)
    {    {
Line 250 
Line 262 
       }       }
       catch(IPCException &)       catch(IPCException &)
       {       {
            PEG_METHOD_EXIT();
          myself->exit_self(0);          myself->exit_self(0);
       }       }
  
       if(_work == 0)       if(_work == 0)
         {
            PEG_METHOD_EXIT();
          throw NullPointer();          throw NullPointer();
         }
       gettimeofday(deadlock_timer, NULL);       gettimeofday(deadlock_timer, NULL);
       _work(parm);       _work(parm);
  
Line 270 
Line 285 
       }       }
       catch(IPCException &)       catch(IPCException &)
       {       {
            PEG_METHOD_EXIT();
          myself->exit_self(0);          myself->exit_self(0);
       }       }
    }    }
    // wait to be awakend by the thread pool destructor    // wait to be awakend by the thread pool destructor
    sleep_sem->wait();    sleep_sem->wait();
    myself->test_cancel();    myself->test_cancel();
   
      PEG_METHOD_EXIT();
    myself->exit_self(0);    myself->exit_self(0);
    return((PEGASUS_THREAD_RETURN)0);    return((PEGASUS_THREAD_RETURN)0);
 } }
Line 288 
Line 305 
  
    throw(IPCException)    throw(IPCException)
 { {
      PEG_METHOD_ENTER(TRC_THREAD, "ThreadPool::allocate_and_awaken");
    struct timeval start;    struct timeval start;
    gettimeofday(&start, NULL);    gettimeofday(&start, NULL);
  
Line 311 
Line 329 
    if(_dying < 1)    if(_dying < 1)
    {    {
       // initialize the thread data with the work function and parameters       // initialize the thread data with the work function and parameters
         Tracer::trace(TRC_THREAD, Tracer::LEVEL4,
             "Initializing thread with work function and parameters: parm = %p",
             parm);
   
       th->remove_tsd("work func");       th->remove_tsd("work func");
       th->put_tsd("work func", NULL,       th->put_tsd("work func", NULL,
                   sizeof( PEGASUS_THREAD_RETURN (PEGASUS_THREAD_CDECL *)(void *)),                   sizeof( PEGASUS_THREAD_RETURN (PEGASUS_THREAD_CDECL *)(void *)),
Line 330 
Line 352 
       if(sleep_sem == 0)       if(sleep_sem == 0)
       {       {
          th->dereference_tsd();          th->dereference_tsd();
            PEG_METHOD_EXIT();
          throw NullPointer();          throw NullPointer();
       }       }
         Tracer::trace(TRC_THREAD, Tracer::LEVEL4, "Signal thread to awaken");
       sleep_sem->signal();       sleep_sem->signal();
       th->dereference_tsd();       th->dereference_tsd();
    }    }
    else    else
       _pool.insert_first(th);       _pool.insert_first(th);
   
      PEG_METHOD_EXIT();
 } }
  
 // caller is responsible for only calling this routine during slack periods // caller is responsible for only calling this routine during slack periods


Legend:
Removed from v.1.13  
changed lines
  Added in v.1.14

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2