library: libThread #include "TSemaphore.h"

# TSemaphore

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

## class TSemaphore : public TObject

| Inheritance Chart:
`TObject`
| <- | `TSemaphore` |

        public:

                          TSemaphore(UInt_t initial = 1)
                          TSemaphore(const TSemaphore&)
                  virtual ~TSemaphore()
           static TClass* Class()
          virtual TClass* IsA() const
              TSemaphore& operator=(const TSemaphore&)
                    Int_t Post()
             virtual void ShowMembers(TMemberInspector& insp, char* parent)
             virtual void Streamer(TBuffer& b)
                     void StreamerNVirtual(TBuffer& b)
                    Int_t TryWait()
                    Int_t Wait()

### Data Members

        private:

              TMutex fMutex  semaphare mutex
          TCondition fCond   semaphore condition variable
               Int_t fValue  counter

## Class Description

     TSemaphore

     This class implements a counting semaphore. Use a semaphore
     to synchronize threads.

TSemaphore(UInt_t initial) : fCond(&fMutex)

     Create counting semaphore.

Int_t Wait()

     If semaphore value is > 0 then decrement it and carry on. If it's
     already 0 then block.

Int_t TryWait()

     If semaphore value is > 0 then decrement it and return 0. If it's
     already 0 then return 1.

Int_t Post()

     If any threads are blocked in Wait(), wake one of them up. Otherwise
     increment the value of the semaphore.

### Inline Functions

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

Author: Fons Rademakers 02/07/97
Last update: root/thread:$Name: $:$Id: TSemaphore.cxx,v 1.2 2004/12/10 12:13:33 rdm Exp $
Copyright (C) 1995-2000, Rene Brun and Fons Rademakers. *