identt
SharedList.hpp
Go to the documentation of this file.
1 
34 #ifndef _IDENTT_UTILS_SHARED_LIST_HPP_
35 #define _IDENTT_UTILS_SHARED_LIST_HPP_
36 
37 #include <list>
38 #include <mutex>
39 
40 namespace identt {
41 namespace utils {
42 template<typename T>
43 class SharedList {
44 public:
54  void emplace_back(const T& t)
55  {
56  std::lock_guard<std::mutex> lock(mutex_);
57  list_.emplace_back(t);
58  }
59 
66  T front()
67  {
68  std::lock_guard<std::mutex> lock(mutex_);
69  return list_.front();
70  }
71 
78  void pop_front()
79  {
80  std::lock_guard<std::mutex> lock(mutex_);
81  list_.pop_front();
82  }
83 
90  void clear()
91  {
92  std::lock_guard<std::mutex> lock(mutex_);
93  list_.clear();
94  }
95 
102  bool empty()
103  {
104  std::lock_guard<std::mutex> lock(mutex_);
105  return list_.empty();
106  }
107 
114  std::size_t size()
115  {
116  std::lock_guard<std::mutex> lock(mutex_);
117  return list_.size();
118  }
119 
120 private:
121  std::list<T> list_;
122  std::mutex mutex_;
123 };
124 
125 } // namespace utils
126 } // namespace identt
127 #undef // _IDENTT_UTILS_SHARED_LIST_HPP_
void clear()
clear : clear
Definition: SharedList.hpp:90
void emplace_back(const T &t)
emplace_back : emplace_back
Definition: SharedList.hpp:54
T front()
front : front
Definition: SharedList.hpp:66
Definition: CryptoBase.hpp:49
void pop_front()
pop_front : pop_front
Definition: SharedList.hpp:78
Definition: SharedList.hpp:43
bool empty()
empty : empty
Definition: SharedList.hpp:102
std::size_t size()
size : size
Definition: SharedList.hpp:114