Logo ROOT  
Reference Guide
TRWSpinLock.hxx
Go to the documentation of this file.
1// @(#)root/thread:$Id$
2// Authors: Enric Tejedor CERN 12/09/2016
3// Philippe Canal FNAL 12/09/2016
4
5/*************************************************************************
6 * Copyright (C) 1995-2016, Rene Brun and Fons Rademakers. *
7 * All rights reserved. *
8 * *
9 * For the licensing terms see $ROOTSYS/LICENSE. *
10 * For the list of contributors see $ROOTSYS/README/CREDITS. *
11 *************************************************************************/
12
13#ifndef ROOT_TRWSpinLock
14#define ROOT_TRWSpinLock
15
16#include "TSpinMutex.hxx"
17
18#include <atomic>
19#include <condition_variable>
20
21namespace ROOT {
23private:
24 std::atomic<int> fReaders; ///<! Number of readers
25 std::atomic<int> fReaderReservation; ///<! A reader wants access
26 std::atomic<int> fWriterReservation; ///<! A writer wants access
27 std::atomic<bool> fWriter; ///<! Is there a writer?
28 ROOT::TSpinMutex fMutex; ///<! RWlock internal mutex
29 std::condition_variable_any fCond; ///<! RWlock internal condition variable
30
31public:
32 ////////////////////////////////////////////////////////////////////////
33 /// Regular constructor.
35
36 void ReadLock();
37 void ReadUnLock();
38 void WriteLock();
39 void WriteUnLock();
40};
41
43private:
45
46public:
49};
50
52private:
54
55public:
58};
59
60} // end of namespace ROOT
61
62#endif
TRWSpinLockReadGuard(TRWSpinLock &lock)
TRWSpinLockWriteGuard(TRWSpinLock &lock)
TRWSpinLock()
Regular constructor.
Definition: TRWSpinLock.hxx:34
void ReadLock()
Acquire the lock in read mode.
Definition: TRWSpinLock.cxx:35
std::condition_variable_any fCond
! RWlock internal condition variable
Definition: TRWSpinLock.hxx:29
std::atomic< int > fReaderReservation
! A reader wants access
Definition: TRWSpinLock.hxx:25
std::atomic< bool > fWriter
! Is there a writer?
Definition: TRWSpinLock.hxx:27
void ReadUnLock()
Release the lock in read mode.
Definition: TRWSpinLock.cxx:61
ROOT::TSpinMutex fMutex
! RWlock internal mutex
Definition: TRWSpinLock.hxx:28
void WriteLock()
Acquire the lock in write mode.
Definition: TRWSpinLock.cxx:77
void WriteUnLock()
Release the lock in write mode.
std::atomic< int > fWriterReservation
! A writer wants access
Definition: TRWSpinLock.hxx:26
std::atomic< int > fReaders
! Number of readers
Definition: TRWSpinLock.hxx:24
A spin mutex class which respects the STL interface for mutexes.
Definition: TSpinMutex.hxx:42
tbb::task_arena is an alias of tbb::interface7::task_arena, which doesn't allow to forward declare tb...