library: libThread #include "TMutex.h"

# TMutex

class description - source file - inheritance tree (.pdf)

## class TMutex : public TVirtualMutex

| Inheritance Chart:
`TObject`
| <- | `TVirtualMutex`
| <- | `TMutex` |

        public:

                                 TMutex(Bool_t recursive = kFALSE)
                                 TMutex(const TMutex&)
                         virtual ~TMutex()
                  static TClass* Class()
                   virtual Int_t CleanUp()
          virtual TVirtualMutex* Factory(Bool_t recursive = kFALSE)
                 virtual TClass* IsA() const
                   virtual Int_t Lock()
                         TMutex& operator=(const TMutex&)
                    virtual void ShowMembers(TMemberInspector& insp, char* parent)
                    virtual void Streamer(TBuffer& b)
                            void StreamerNVirtual(TBuffer& b)
                   virtual Int_t TryLock()
                   virtual Int_t UnLock()

### Data Members

        private:

          TMutexImp* fMutexImp  pointer to mutex implementation
              Long_t fId        id of thread which locked mutex
               Int_t fRef       reference count in case of recursive locking by same thread

## Class Description

     TMutex

     This class implements mutex locks. A mutex is a mutual exclusive
     lock. The actual work is done via the TMutexImp class (either
     TPosixMutex or TWin32Mutex).

TMutex(Bool_t recursive)

     Create a mutex lock. The actual mutex implementation will be
     provided via the TThreadFactory.

Int_t Lock()

     Lock the mutex. Returns 0 when no error, EDEADLK when mutex was already
     locked by this thread and this mutex is not reentrant.

Int_t TryLock()

     Try to lock mutex. Returns 0 when no error, EDEADLK when mutex was
     already locked by this thread and this mutex is not reentrant.

Int_t UnLock()

     Unlock the mutex. Returns 0 when no error, EPERM when mutex was already
     unlocked by this thread.

Int_t CleanUp()

     Clean up of mutex if it belongs to thread.

TVirtualMutex* Factory(Bool_t recursive)

     Create mutex and return pointer to it. Calling function must care
     about proper deletion. The function is intended to be used in connection
     with the R__LOCKGUARD2 macro for local thread protection. Since "new" is
     used the TStorage class has to be protected by gGlobalMutex.

### Inline Functions

                   void ~TMutex()
                TClass* Class()
                TClass* IsA() const
                   void ShowMembers(TMemberInspector& insp, char* parent)
                   void Streamer(TBuffer& b)
                   void StreamerNVirtual(TBuffer& b)
                 TMutex TMutex(const TMutex&)
                TMutex& operator=(const TMutex&)

Author: Fons Rademakers 26/06/97
Last update: root/thread:$Name: $:$Id: TMutex.cxx,v 1.6 2005/06/23 00:29:38 rdm Exp $
Copyright (C) 1995-2000, Rene Brun and Fons Rademakers. *