libebml_ng
locks.h
Go to the documentation of this file.
1 #ifndef EBML_NG_LAZYLOAD_LOCK_H
2 #define EBML_NG_LAZYLOAD_LOCK_H
3 
4 #include <mutex>
5 #include <shared_mutex>
6 #include <unordered_set>
7 #include <vector>
8 #include <deque>
9 
10 namespace ebml {
11  class ebmlLazyLoad;
12 
13  class readLock_t {
14  friend class ebmlLazyLoad;
15 
16  protected:
17  mutable std::vector<std::shared_lock<std::shared_mutex>> locks;
19  readLock_t(std::vector<std::shared_lock<std::shared_mutex>>&&, const ebmlLazyLoad*);
20 
21  public:
24  readLock_t& operator=(const readLock_t&) = delete;
25  };
26 
27  class writeLock_t {
28  friend class ebmlLazyLoad;
29 
30  protected:
31  std::vector<std::shared_lock<std::shared_mutex>> rlocks;
32  std::unique_lock<std::shared_mutex> wlock;
34  mutable std::unordered_set<const ebmlLazyLoad*> cache;
35  mutable std::deque<const ebmlLazyLoad*> order;
36 
37  writeLock_t(std::unique_lock<std::shared_mutex>&&, const ebmlLazyLoad*);
38  writeLock_t(std::vector<std::shared_lock<std::shared_mutex>>&&, std::unique_lock<std::shared_mutex>&&, const ebmlLazyLoad*);
39  void _addToCache(const ebmlLazyLoad*) const;
40 
41  public:
44  writeLock_t& operator=(const writeLock_t&) = delete;
45  };
46 }
47 #endif
readLock_t & operator=(readLock_t &&)
Definition: locks.cpp:13
readLock_t(std::vector< std::shared_lock< std::shared_mutex >> &&, const ebmlLazyLoad *)
Definition: locks.cpp:8
Definition: locks.h:13
void _addToCache(const ebmlLazyLoad *) const
std::unordered_set< const ebmlLazyLoad * > cache
Definition: locks.h:34
Definition: basictypes.h:40
std::deque< const ebmlLazyLoad * > order
Definition: locks.h:35
std::vector< std::shared_lock< std::shared_mutex > > locks
Definition: locks.h:17
Represents an EBML Master Element with on-disk, transactional child management.
Definition: ebmlLazyLoad.h:85
const ebmlLazyLoad * elem
Definition: locks.h:33
writeLock_t & operator=(writeLock_t &&)
Definition: locks.cpp:30
std::unique_lock< std::shared_mutex > wlock
Definition: locks.h:32
std::vector< std::shared_lock< std::shared_mutex > > rlocks
Definition: locks.h:31
writeLock_t(std::unique_lock< std::shared_mutex > &&, const ebmlLazyLoad *)
Definition: locks.cpp:23
const ebmlLazyLoad * elem
Definition: locks.h:18
Definition: locks.h:27