Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
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
TRWSpinLock()
Regular constructor.
void ReadLock()
Acquire the lock in read mode.
std::condition_variable_any fCond
! RWlock internal condition variable
std::atomic< int > fReaderReservation
! A reader wants access
std::atomic< bool > fWriter
! Is there a writer?
void ReadUnLock()
Release the lock in read mode.
ROOT::TSpinMutex fMutex
! RWlock internal mutex
void WriteLock()
Acquire the lock in write mode.
void WriteUnLock()
Release the lock in write mode.
std::atomic< int > fWriterReservation
! A writer wants access
std::atomic< int > fReaders
! Number of readers
A spin mutex class which respects the STL interface for mutexes.
tbb::task_arena is an alias of tbb::interface7::task_arena, which doesn't allow to forward declare tb...