55 std::recursive_mutex& _mutex;
91 throw cbeam::error::runtime_error(
"cbeam::container::thread_safe_container::get_lock_guard: not allowed during destruction of the container.");
101 assert(!
_is_being_modified &&
"cbeam::container::thread_safe_container: destruction during modification or duplicate destruction");
110 std::lock_guard<std::recursive_mutex> lock(
_mutex);
117 std::lock_guard<std::recursive_mutex> lock(
_mutex);
120 throw cbeam::error::runtime_error(
"cbeam::container::thread_safe_container::clear: not allowed during modification of the container.");
131 std::lock_guard<std::recursive_mutex> lock(
_mutex);
138 std::lock_guard<std::recursive_mutex> lock(
_mutex);
145 std::lock_guard<std::recursive_mutex> lock(
_mutex);
Inner class providing RAII-style locking mechanism.
Definition thread_safe_container.hpp:54
lock_guard & operator=(const lock_guard &)=delete
lock_guard(const lock_guard &)=delete
lock_guard(std::recursive_mutex &mutex)
Constructs the lock guard and locks the provided mutex.
Definition thread_safe_container.hpp:61
~lock_guard() noexcept
Destructor that unlocks the mutex.
Definition thread_safe_container.hpp:68
T _container
Internal non-thread safe container.
Definition thread_safe_container.hpp:156
void clear()
Clears the contents.
Definition thread_safe_container.hpp:115
std::atomic< bool > _is_being_modified
Definition thread_safe_container.hpp:157
lock_guard get_lock_guard() const
Acquires a lock guard for the set, ensuring thread safety.
Definition thread_safe_container.hpp:87
bool empty() const
Checks if the container is empty.
Definition thread_safe_container.hpp:108
thread_safe_container()=default
Default constructor.
std::size_t size() const
Returns the number of elements.
Definition thread_safe_container.hpp:129
auto begin()
Returns an iterator to the beginning.
Definition thread_safe_container.hpp:136
bool is_being_modified() const
Definition thread_safe_container.hpp:149
auto end()
Returns an iterator to the end.
Definition thread_safe_container.hpp:143
std::recursive_mutex _mutex
Mutex to protect access to _container.
Definition thread_safe_container.hpp:155
virtual ~thread_safe_container() noexcept
Definition thread_safe_container.hpp:99
A Cbeam-specific runtime error that also acts like std::runtime_error.
Definition runtime_error.hpp:46
A helper that sets the given variable to a new value, and restores the original value on destruction.
Definition scoped_set.hpp:61
Offers advanced container types with unique approaches to stability and interprocess sharing....
Definition buffer.hpp:44