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

Diff for /pegasus/src/Pegasus/Common/Threads.h between version 1.1.2.1 and 1.1.2.2

version 1.1.2.1, 2006/07/27 23:11:52 version 1.1.2.2, 2006/07/28 17:41:27
Line 36 
Line 36 
 #ifndef Pegasus_Threads_h #ifndef Pegasus_Threads_h
 #define Pegasus_Threads_h #define Pegasus_Threads_h
  
   #include <cstring>
 #include <Pegasus/Common/Config.h> #include <Pegasus/Common/Config.h>
 #include <Pegasus/Common/Linkage.h> #include <Pegasus/Common/Linkage.h>
  
Line 68 
Line 69 
  
 //============================================================================== //==============================================================================
 // //
 // ThreadCleanupType  // Thread-related type definitions
 // //
 //============================================================================== //==============================================================================
  
 struct ThreadCleanupBuffer  #if defined(PEGASUS_HAVE_PTHREADS)
   
   struct ThreadType
 { {
     void (*__routine)(void*);  public:
     void* __arg;  
     int __canceltype;  
     struct ThreadCleanupBuffer* __prev;  
 };  
  
 #if defined(PEGASUS_PLATFORM_AIX_RS_IBMCXX)      ThreadType()
 typedef void* ThreadCleanupType;      {
 #elif defined(PEGASUS_PLATFORM_HPUX_ACC)          clear();
 typedef __pthread_cleanup_handler_t ThreadCleanupType;      }
 #elif defined(PEGASUS_PLATFORM_OS400_ISERIES_IBM)  
 typedef ThreadCleanupBuffer ThreadCleanupType;  
 #elif defined(PEGASUS_PLATFORM_ZOS_ZSERIES_IBM)  
 typedef ThreadCleanupBuffer ThreadCleanupType;  
 #elif defined(PEGASUS_PLATFORM_SOLARIS_SPARC_GNU)  
 typedef _cleanup_t ThreadCleanupType;  
 #elif defined(PEGASUS_PLATFORM_TRU64_ALPHA_DECCXX)  
 typedef void* ThreadCleanupType;  
 #elif defined(PEGASUS_DARWIN_PPC_GNU)  
 typedef void* ThreadCleanupType;  
 #elif defined(PEGASUS_OS_VMS)  
 typedef void* ThreadCleanupType;  
 #elif defined(PEGASUS_PLATFORM_WIN32_IX86_MSVC)  
 typedef void* ThreadCleanupType;  
 #elif defined(PEGASUS_PLATFORM_LINUX_GENERIC_GNU)  
 typedef struct _pthread_cleanup_buffer ThreadCleanupType;  
 #else  
 # error "<Pegasus/Common/Threads.h>: unsupported platform"  
 #endif  
  
 //==============================================================================      ThreadType(const ThreadType& x) : _thread(x._thread), _id(x._id)
 //      {
 // Thread-related type definitions      }
 //  
 //==============================================================================      ThreadType(pthread_t thread, Uint32 id) : _thread(thread), _id(id)
       {
       }
   
       ThreadType& operator=(const ThreadType& x)
       {
           if (&x != this)
           {
               _id = x._id;
               _thread = x._thread;
           }
           return *this;
       }
   
       void clear()
       {
           memset(this, 0, sizeof(*this));
       }
   
       pthread_t thread() const
       {
           return _thread;
       }
   
       Uint32 id() const
       {
           return _id;
       }
   
       void print() const
       {
           printf("ThreadType(%lu, %lu)\n", _thread, (unsigned long)_id);
       }
   
   private:
       pthread_t _thread;
   
       // And id of zero indicates a null object. 1 indicates the main thread.
       Uint32 _id;
   };
  
 #if defined(PEGASUS_HAVE_PTHREADS)  
 typedef pthread_t ThreadType;  
 typedef void* ThreadReturnType; typedef void* ThreadReturnType;
 #endif #endif
  
Line 150 
Line 167 
 { {
 public: public:
  
       enum Type { DETACHED, JOINABLE };
   
       static int create(
           ThreadType& thread,
           Type type,
           void* (*start)(void*),
           void* arg);
   
     static ThreadType self();     static ThreadType self();
  
     static bool equal(ThreadType x, ThreadType y);     static bool equal(ThreadType x, ThreadType y);
Line 162 
Line 187 
  
     static void sleep(int msec);     static void sleep(int msec);
  
     static void cleanup_push(void (*func)(void*), void* arg);      static void cleanup_push(void (*start)(void*), void* arg);
  
     static void cleanup_pop(int execute);     static void cleanup_pop(int execute);
 }; };
Line 175 
Line 200 
  
 #if defined(PEGASUS_HAVE_PTHREADS) #if defined(PEGASUS_HAVE_PTHREADS)
  
 inline ThreadType Threads::self()  
 {  
     return pthread_self();  
 }  
   
 inline bool Threads::equal(ThreadType x, ThreadType y) inline bool Threads::equal(ThreadType x, ThreadType y)
 { {
     return pthread_equal(x, y);      return pthread_equal(x.thread(), y.thread());
 } }
  
 inline void Threads::exit(ThreadReturnType rc) inline void Threads::exit(ThreadReturnType rc)
Line 192 
Line 212 
  
 inline void Threads::cancel(ThreadType th, ThreadReturnType rc) inline void Threads::cancel(ThreadType th, ThreadReturnType rc)
 { {
     pthread_cancel(th);      pthread_cancel(th.thread());
 } }
  
 inline void Threads::yield() inline void Threads::yield()
Line 267 
Line 287 
 { {
     // ATTN: Not implemented on Windows.     // ATTN: Not implemented on Windows.
 } }
   
 #endif /* defined(PEGASUS_HAVE_WINDOWS_THREADS) */ #endif /* defined(PEGASUS_HAVE_WINDOWS_THREADS) */
  
 PEGASUS_NAMESPACE_END PEGASUS_NAMESPACE_END


Legend:
Removed from v.1.1.2.1  
changed lines
  Added in v.1.1.2.2

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2