OSSIA
Open Scenario System for Interactive Application
locked_container.hpp
Go to the documentation of this file.
1 #pragma once
2 #include <ossia/detail/mutex.hpp>
3 
7 // #include <ossia/detail/logger.hpp>
8 namespace ossia
9 {
13 template <typename Container>
15 {
16 public:
17  locked_container(Container& src, shared_mutex_t& mutex)
18  : m_ref{src}
19  , m_mutex{mutex}
20  {
21  // SPDLOG_TRACE((&ossia::logger()), "locking(container)");
22  }
23 
25  {
26  // SPDLOG_TRACE((&ossia::logger()), "unlocking(container)");
27  }
28 
29  auto& front() { return m_ref.front(); }
30  const auto& front() const { return m_ref.front(); }
31 
32  auto empty() const { return m_ref.empty(); }
33 
34  auto size() const { return m_ref.size(); }
35  auto begin() const { return m_ref.cbegin(); }
36  auto end() const { return m_ref.cend(); }
37  auto cbegin() const { return m_ref.cbegin(); }
38  auto cend() const { return m_ref.cend(); }
39  auto begin() { return m_ref.begin(); }
40  auto end() { return m_ref.end(); }
41  auto cbegin() { return m_ref.cbegin(); }
42  auto cend() { return m_ref.cend(); }
43 
44  auto& operator[](std::size_t i) { return m_ref[i]; }
45  const auto& operator[](std::size_t i) const { return m_ref[i]; }
46 
47 private:
48  Container& m_ref;
49  read_lock_t m_mutex;
50 };
51 }
Thread-safe read-only reference to a container.
Definition: locked_container.hpp:15
Definition: git_info.h:7