//*CMZ :  2.23/12 30/12/99  01.01.59  by  Fons Rademakers
//*CMZ :  2.00/00 04/11/97  09.59.07  by  Victor Perev
//*CMZ :  1.03/03 25/08/97  16.25.33  by  Fons Rademakers
//*-- Author :    Fons Rademakers   25/06/97

//*KEEP,CopyRight,T=C.
/*************************************************************************
 * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers.               *
 * All rights reserved.                                                  *
 *                                                                       *
 * For the licensing terms see $ROOTSYS/LICENSE.                         *
 * For the list of contributors see $ROOTSYS/README/CREDITS.             *
 *************************************************************************/
//*KEND.

//////////////////////////////////////////////////////////////////////////
//                                                                      //
// TPosixMutex                                                          //
//                                                                      //
// This class provides an interface to the posix mutex routines.        //
//                                                                      //
//////////////////////////////////////////////////////////////////////////

//*KEEP,TThread,T=C++.
#include "TThread.h"
//*KEEP,TPosixMutex,T=C++,IF=POSIX.
#include "TPosixMutex.h"
//*KEEP,PosixThreadInc,T=C++,IF=POSIX.
#include "PosixThreadInc.h"
//*KEND.

ClassImp(TPosixMutex)

//______________________________________________________________________________
 TPosixMutex::TPosixMutex()
{
   // Create a posix mutex lock.

#if (PthreadDraftVersion == 4)
   int rc = ERRNO(pthread_mutex_init(&fMutex, pthread_mutexattr_default));
#else
   int rc = ERRNO(pthread_mutex_init(&fMutex, 0));
#endif
   if (rc != 0)
      SysError("TMutex", "pthread_mutex_init error");
}

//______________________________________________________________________________
 TPosixMutex::~TPosixMutex()
{
   // TMutex dtor.

   int rc = ERRNO(pthread_mutex_destroy(&fMutex));
   if (rc != 0)
      SysError("~TMutex", "pthread_mutex_destroy error");
}

//______________________________________________________________________________
 Int_t TPosixMutex::Lock()
{
   // Lock the mutex.

   return ERRNO(pthread_mutex_lock(&fMutex));
}

//______________________________________________________________________________
 Int_t TPosixMutex::TryLock()
{
   // Try locking the mutex. Returns 0 if mutex can be locked.

   return ERRNO(pthread_mutex_trylock(&fMutex));
}

//______________________________________________________________________________
 Int_t TPosixMutex::UnLock(void)
{
   // Unlock the mutex.

   return ERRNO(pthread_mutex_unlock(&fMutex));
}


ROOT page - Class index - Top of the page

This page has been automatically generated. If you have any comments or suggestions about the page layout send a mail to ROOT support, or contact the developers with any questions or problems regarding ROOT.