Samchon Framework for CPP  1.0.0
SharedReadLock.hpp
1 #pragma once
2 #include <samchon/API.hpp>
3 
4 namespace std
5 {
6  template <typename T>
7  struct atomic;
8 };
9 namespace samchon
10 {
11 namespace library
12 {
13  class RWMutex;
14 
50  class SAMCHON_FRAMEWORK_API SharedReadLock
51  {
52  private:
57 
61  std::atomic<size_t> *reference;
62 
66  std::atomic<bool> *isLocked;
67 
68  public:
69  /* -----------------------------------------------------------
70  CONSTRUCTORS
71  ----------------------------------------------------------- */
78  SharedReadLock(const RWMutex &, bool = true);
79 
84 
89 
93  ~SharedReadLock();
94 
95  /* -----------------------------------------------------------
96  LOCKERS
97  ----------------------------------------------------------- */
101  void lock() const;
102 
106  void unlock() const;
107 
111  //auto tryLock() const -> bool;
112  };
113 };
114 };
Shared lock from a RWMutex.
const RWMutex * semaphore
Managed RWMutex.
std::atomic< size_t > * reference
Referencing count sharing same RWMutex.
Definition: RWMutex.hpp:4
std::atomic< bool > * isLocked
Whether the mutex was locked by SharedReadLock.
Top level namespace of products built from samchon.
Definition: ByteArray.hpp:7