Cbeam
|
Base class for thread safe containers. More...
#include <thread_safe_container.hpp>
Classes | |
class | lock_guard |
Inner class providing RAII-style locking mechanism. More... | |
Public Member Functions | |
lock_guard | get_lock_guard () const |
Acquires a lock guard for the set, ensuring thread safety. | |
thread_safe_container ()=default | |
Default constructor. | |
virtual | ~thread_safe_container () noexcept |
bool | empty () const |
Checks if the container is empty. | |
void | clear () |
Clears the contents. | |
std::size_t | size () const |
Returns the number of elements. | |
auto | begin () |
Returns an iterator to the beginning. | |
auto | end () |
Returns an iterator to the end. | |
bool | is_being_modified () const |
Protected Attributes | |
std::recursive_mutex | _mutex |
Mutex to protect access to _container. | |
T | _container |
Internal non-thread safe container. | |
std::atomic< bool > | _is_being_modified {false} |
Base class for thread safe containers.
T | Type of the container |
|
default |
Default constructor.
|
inlinevirtualnoexcept |
|
inline |
Returns an iterator to the beginning.
|
inline |
Clears the contents.
|
inline |
Checks if the container is empty.
|
inline |
Returns an iterator to the end.
|
inline |
Acquires a lock guard for the set, ensuring thread safety.
This method provides a mechanism to acquire a lock on the set's mutex, ensuring that no other thread can modify the set while the lock is held. The returned lock guard object will release the lock when it goes out of scope.
cbeam::error::runtime_error | if the set is being modified during the call. |
|
inline |
|
inline |
Returns the number of elements.
|
protected |
Internal non-thread safe container.
|
protected |
|
mutableprotected |
Mutex to protect access to _container.