Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
TMutex.h
Go to the documentation of this file.
1// @(#)root/thread:$Id$
2// Author: Fons Rademakers 26/06/97
3
4/*************************************************************************
5 * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers. *
6 * All rights reserved. *
7 * *
8 * For the licensing terms see $ROOTSYS/LICENSE. *
9 * For the list of contributors see $ROOTSYS/README/CREDITS. *
10 *************************************************************************/
11
12#ifndef ROOT_TMutex
13#define ROOT_TMutex
14
15
16//////////////////////////////////////////////////////////////////////////
17// //
18// TMutex //
19// //
20// This class implements mutex locks. A mutex is a mutual exclusive //
21// lock. The actual work is done via the TMutexImp class (either //
22// TPosixMutex or TWin32Mutex). //
23// //
24//////////////////////////////////////////////////////////////////////////
25
26#include "TVirtualMutex.h"
27#include "TMutexImp.h"
28
29
30class TMutex : public TVirtualMutex {
31
32friend class TCondition;
33friend class TThread;
34
35private:
36 TMutexImp *fMutexImp; // pointer to mutex implementation
37
38 TMutex(const TMutex&) = delete;
39 TMutex& operator=(const TMutex&) = delete;
40
41public:
42 TMutex(Bool_t recursive = kFALSE);
43 virtual ~TMutex() { delete fMutexImp; }
44
45 Int_t Lock() override;
46 Int_t TryLock() override;
47 Int_t UnLock() override;
48 Int_t CleanUp() override;
49
50 // Compatibility with standard library
51 void lock() { TMutex::Lock(); }
52 void unlock() { TMutex::UnLock(); }
53
54 TVirtualMutex *Factory(Bool_t recursive = kFALSE) override;
55
56 ClassDefOverride(TMutex,0) // Mutex lock class
57};
58
59#endif
bool Bool_t
Definition RtypesCore.h:63
int Int_t
Definition RtypesCore.h:45
constexpr Bool_t kFALSE
Definition RtypesCore.h:94
#define ClassDefOverride(name, id)
Definition Rtypes.h:346
void unlock()
Definition TMutex.h:52
void lock()
Definition TMutex.h:51
Int_t CleanUp() override
Clean up of mutex.
Definition TMutex.cxx:76
TMutex & operator=(const TMutex &)=delete
Int_t UnLock() override
Unlock the mutex.
Definition TMutex.cxx:68
virtual ~TMutex()
Definition TMutex.h:43
Int_t TryLock() override
Try to lock mutex.
Definition TMutex.cxx:57
TMutexImp * fMutexImp
Definition TMutex.h:36
TMutex(const TMutex &)=delete
Int_t Lock() override
Lock the mutex.
Definition TMutex.cxx:46
<div class="legacybox"><h2>Legacy Code</h2> TThread is a legacy interface: there will be no bug fixes...
Definition TThread.h:40
This class implements a mutex interface.