(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.90.2.9 and 1.98

version 1.90.2.9, 2006/07/29 15:54:07 version 1.98, 2006/11/10 18:14:58
Line 29 
Line 29 
 // //
 //============================================================================== //==============================================================================
 // //
 // Author: Mike Day (mdday@us.ibm.com)  
 //  
 // Modified By: Rudy Schuet (rudy.schuet@compaq.com) 11/12/01  
 //              added nsk platform support  
 //              Roger Kumpf, Hewlett-Packard Company (roger_kumpf@hp.com)  
 //              Amit K Arora, IBM (amita@in.ibm.com) for PEP#101  
 //              Sean Keenan, Hewlett-Packard Company (sean.keenan@hp.com)  
 //              David Dillard, VERITAS Software Corp.  
 //                  (david.dillard@veritas.com)  
 //  
 //%///////////////////////////////////////////////////////////////////////////// //%/////////////////////////////////////////////////////////////////////////////
  
 #include "Thread.h" #include "Thread.h"
   #include <errno.h>
 #include <exception> #include <exception>
 #include <Pegasus/Common/Tracer.h> #include <Pegasus/Common/Tracer.h>
 #include "Time.h" #include "Time.h"
Line 77 
Line 68 
 void Thread::cancel() void Thread::cancel()
 { {
     _cancelled = true;     _cancelled = true;
     pthread_cancel(_handle.thid.tt_handle());      pthread_cancel(_handle.thid.thread);
 } }
  
 void Thread::test_cancel() void Thread::test_cancel()
Line 89 
Line 80 
 #endif #endif
 } }
  
 Boolean Thread::is_cancelled(void)  Boolean Thread::is_cancelled()
 { {
     return _cancelled;     return _cancelled;
 } }
Line 109 
Line 100 
 #if defined(PEGASUS_PLATFORM_LINUX_GENERIC_GNU) #if defined(PEGASUS_PLATFORM_LINUX_GENERIC_GNU)
 void Thread::suspend() void Thread::suspend()
 { {
     pthread_kill(_handle.thid.tt_handle(), SIGSTOP);      pthread_kill(_handle.thid.thread, SIGSTOP);
 } }
  
 void Thread::resume() void Thread::resume()
 { {
     pthread_kill(_handle.thid.tt_handle(), SIGCONT);      pthread_kill(_handle.thid.thread, SIGCONT);
 } }
 #endif #endif
  
Line 123 
Line 114 
     Threads::sleep(msec);     Threads::sleep(msec);
 } }
  
 void Thread::join(void)  void Thread::join()
 { {
     if (!_is_detached && Threads::id(_handle.thid) != 0)      if (!_is_detached && !Threads::null(_handle.thid))
         pthread_join(_handle.thid.tt_handle(), &_exit_code);          pthread_join(_handle.thid.thread, &_exit_code);
  
     Threads::clear(_handle.thid);     Threads::clear(_handle.thid);
 } }
  
 void Thread::thread_init(void)  void Thread::thread_init()
 { {
 #if defined(PEGASUS_PLATFORM_ZOS_ZSERIES_IBM) #if defined(PEGASUS_PLATFORM_ZOS_ZSERIES_IBM)
     pthread_setintr(PTHREAD_INTR_ENABLE);     pthread_setintr(PTHREAD_INTR_ENABLE);
Line 143 
Line 134 
     _cancel_enabled = true;     _cancel_enabled = true;
 } }
  
 void Thread::detach(void)  void Thread::detach()
 { {
     _is_detached = true;     _is_detached = true;
     pthread_detach(_handle.thid.tt_handle());  #if defined(PEGASUS_PLATFORM_ZOS_ZSERIES_IBM)
       pthread_t  thread_id=_handle.thid.thread;
       pthread_detach(&thread_id);
   #else
       pthread_detach(_handle.thid.thread);
   #endif
 } }
  
 ThreadStatus Thread::run() ThreadStatus Thread::run()
Line 164 
Line 160 
     // are no insufficient memory.  Hence we are checking for both.  See bug     // are no insufficient memory.  Hence we are checking for both.  See bug
     // 386.     // 386.
  
       if (rc == -1)
           rc = errno;
     if ((rc == EAGAIN) || (rc == ENOMEM))     if ((rc == EAGAIN) || (rc == ENOMEM))
     {     {
         Threads::clear(_handle.thid);         Threads::clear(_handle.thid);
Line 202 
Line 200 
 //     sigaddset(sig, SIGUSR1); //     sigaddset(sig, SIGUSR1);
 //     sigaddset(sig, SIGUSR2); //     sigaddset(sig, SIGUSR2);
 // #endif // #endif
 #ifndef PEGASUS_PLATFORM_ZOS_ZSERIES_IBM  #if defined (PEGASUS_PLATFORM_ZOS_ZSERIES_IBM) || defined (PEGASUS_OS_VMS)
     pthread_sigmask(SIG_BLOCK, sig, NULL);  
 #else  
     sigprocmask(SIG_BLOCK, sig, NULL);     sigprocmask(SIG_BLOCK, sig, NULL);
   #else
       pthread_sigmask(SIG_BLOCK, sig, NULL);
 #endif #endif
     return sig;     return sig;
 } }
  
 Thread::Thread(ThreadReturnType(PEGASUS_THREAD_CDECL * start) (void *), void *parameter, Boolean detached):_is_detached(detached),  Thread::Thread(
       ThreadReturnType(PEGASUS_THREAD_CDECL* start) (void*),
       void* parameter,
       Boolean detached)
       : _is_detached(detached),
 _cancel_enabled(true), _cancel_enabled(true),
 _cancelled(false), _cancelled(false),
 _start(start), _cleanup(), _tsd(), _thread_parm(parameter), _exit_code(0)        _start(start),
         _cleanup(),
         _tsd(),
         _thread_parm(parameter),
         _exit_code(0)
 { {
     Threads::clear(_handle.thid);     Threads::clear(_handle.thid);
 } }
Line 241 
Line 247 
  
 #if defined(PEGASUS_HAVE_WINDOWS_THREADS) #if defined(PEGASUS_HAVE_WINDOWS_THREADS)
  
 ThreadStatus Thread::run(void)  ThreadStatus Thread::run()
 { {
     // Note: A Win32 thread ID is not the same thing as a pthread ID.     // Note: A Win32 thread ID is not the same thing as a pthread ID.
     // Win32 threads have both a thread ID and a handle.  The handle     // Win32 threads have both a thread ID and a handle.  The handle
Line 254 
Line 260 
     tt.handle = (HANDLE) _beginthreadex(NULL, 0, _start, this, 0, &threadid);     tt.handle = (HANDLE) _beginthreadex(NULL, 0, _start, this, 0, &threadid);
     _handle.thid = tt;     _handle.thid = tt;
  
     if (Threads::id(_handle.thid) == 0)      if (Threads::null(_handle.thid))
     {     {
         if (errno == EAGAIN)         if (errno == EAGAIN)
         {         {
Line 268 
Line 274 
     return PEGASUS_THREAD_OK;     return PEGASUS_THREAD_OK;
 } }
  
 void Thread::cancel(void)  void Thread::cancel()
 { {
     _cancelled = true;     _cancelled = true;
 } }
  
 void Thread::test_cancel(void)  void Thread::test_cancel()
 { {
     if (_cancel_enabled && _cancelled)     if (_cancel_enabled && _cancelled)
     {     {
Line 281 
Line 287 
     }     }
 } }
  
 Boolean Thread::is_cancelled(void)  Boolean Thread::is_cancelled()
 { {
     return _cancelled;     return _cancelled;
 } }
  
 void Thread::thread_switch(void)  void Thread::thread_switch()
 { {
     Sleep(0);     Sleep(0);
 } }
Line 296 
Line 302 
     Sleep(milliseconds);     Sleep(milliseconds);
 } }
  
 void Thread::join(void)  void Thread::join()
 { {
     if (Threads::id(_handle.thid) != 0)      if (!Threads::null(_handle.thid))
     {     {
         if (!_is_detached)         if (!_is_detached)
         {         {
Line 330 
Line 336 
     }     }
 } }
  
 void Thread::thread_init(void)  void Thread::thread_init()
 { {
     _cancel_enabled = true;     _cancel_enabled = true;
 } }
  
 void Thread::detach(void)  void Thread::detach()
 { {
     _is_detached = true;     _is_detached = true;
 } }
Line 418 
Line 424 
 } }
  
  
 //thread_data *Thread::put_tsd(const Sint8 *key, void (*delete_func)(void *), Uint32 size, void *value)  
   
   
 void Thread::exit_self(ThreadReturnType exit_code) void Thread::exit_self(ThreadReturnType exit_code)
 { {
 #if defined(PEGASUS_PLATFORM_HPUX_ACC) || \  #ifndef PEGASUS_PLATFORM_AIX_RS_IBMCXX
     defined(PEGASUS_PLATFORM_LINUX_GENERIC_GNU)      Threads::exit(exit_code);
     // NOTE: pthread_exit exhibits unusual behavior on RHEL 3 U2, as  
     // documented in Bugzilla 3836.  Where feasible, it may be advantageous  
     // to avoid using this function.  
     pthread_exit(exit_code);  
 #else #else
     // execute the cleanup stack and then return     // execute the cleanup stack and then return
     while (_cleanup.size())     while (_cleanup.size())
Line 526 
Line 525 
     return acceptLangs;     return acceptLangs;
 } }
  
 void Thread::setLanguages(AcceptLanguageList * langs)   // l10n  void Thread::setLanguages(AcceptLanguageList * langs)
 { {
     PEG_METHOD_ENTER(TRC_THREAD, "Thread::setLanguages");     PEG_METHOD_ENTER(TRC_THREAD, "Thread::setLanguages");
  
Line 542 
Line 541 
     PEG_METHOD_EXIT();     PEG_METHOD_EXIT();
 } }
  
 void Thread::clearLanguages()   // l10n  void Thread::clearLanguages()
 { {
     PEG_METHOD_ENTER(TRC_THREAD, "Thread::clearLanguages");     PEG_METHOD_ENTER(TRC_THREAD, "Thread::clearLanguages");
  


Legend:
Removed from v.1.90.2.9  
changed lines
  Added in v.1.98

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2