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

Diff for /pegasus/src/Pegasus/Common/Mutex.h between version 1.8 and 1.9

version 1.8, 2006/09/22 23:12:47 version 1.9, 2006/10/03 17:34:53
Line 107 
Line 107 
  
     void unlock();     void unlock();
  
   #if defined(PEGASUS_OS_LINUX)
       /**
           This method must only be called after a fork() to reset the mutex
           lock status in the new process.  Any other use of this method is
           unsafe.
       */
       void reinitialize();
   #endif
   
 private: private:
     Mutex(const Mutex&);     Mutex(const Mutex&);
     Mutex& operator=(const Mutex&);     Mutex& operator=(const Mutex&);
Line 145 
Line 154 
     Mutex& _mutex;     Mutex& _mutex;
 }; };
  
   //==============================================================================
   //
   // PEGASUS_FORK_SAFE_MUTEX
   //
   //==============================================================================
   
   // Use of this macro ensures that a static Mutex is not locked across a fork().
   
   #if !defined(PEGASUS_HAVE_PTHREADS) || \
       defined(PEGASUS_OS_ZOS) || \
       defined(PEGASUS_OS_VMS)
   
   # define PEGASUS_FORK_SAFE_MUTEX(mutex)
   
   #elif defined(PEGASUS_OS_LINUX)
   
   # define PEGASUS_FORK_SAFE_MUTEX(mutex)  \
       class ForkSafeMutex ## mutex         \
       {                                    \
       public:                              \
           ForkSafeMutex ## mutex()         \
           {                                \
               pthread_atfork(              \
                   0,                       \
                   0,                       \
                   _reinitializeMutex);     \
           }                                \
                                            \
       private:                             \
           static void _reinitializeMutex() \
           {                                \
               mutex.reinitialize();        \
           }                                \
       };                                   \
                                            \
       static ForkSafeMutex ## mutex __forkSafeMutex ## mutex;
   
   #else
   
   # define PEGASUS_FORK_SAFE_MUTEX(mutex)  \
       class ForkSafeMutex ## mutex         \
       {                                    \
       public:                              \
           ForkSafeMutex ## mutex()         \
           {                                \
               pthread_atfork(              \
                   _lockMutex,              \
                   _unlockMutex,            \
                   _unlockMutex);           \
           }                                \
                                            \
       private:                             \
           static void _lockMutex()         \
           {                                \
               mutex.lock();                \
           }                                \
                                            \
           static void _unlockMutex()       \
           {                                \
               mutex.unlock();              \
           }                                \
       };                                   \
                                            \
       static ForkSafeMutex ## mutex __forkSafeMutex ## mutex;
   
   #endif
   
 PEGASUS_NAMESPACE_END PEGASUS_NAMESPACE_END
  
 #endif /* Pegasus_Mutex_h */ #endif /* Pegasus_Mutex_h */


Legend:
Removed from v.1.8  
changed lines
  Added in v.1.9

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2