|
Container System 0.1.0
High-performance C++20 type-safe container framework with SIMD-accelerated serialization
|
Snapshot-based reader for frequently accessed data. More...
#include <thread_safe_container.h>

Public Types | |
| using | snapshot_ptr = std::shared_ptr<const thread_safe_container::value_map> |
Public Member Functions | |
| snapshot_reader (std::shared_ptr< thread_safe_container > container) | |
| template<concepts::ValueVariantType T> | |
| std::optional< T > | get (std::string_view key) const |
| Get value from snapshot (lock-protected read of snapshot) | |
| void | update_snapshot () |
| Update snapshot from container. | |
Private Attributes | |
| std::shared_ptr< thread_safe_container > | container_ |
| snapshot_ptr | snapshot_ |
| std::shared_mutex | snapshot_mutex_ |
Snapshot-based reader for frequently accessed data.
Uses a snapshot pattern to provide read access with reduced lock contention. Note: This is not truly lock-free, as it uses a shared_mutex internally. The snapshot is updated explicitly, allowing multiple reads without acquiring the main container lock. This is useful for read-heavy workloads where slightly stale data is acceptable.
Definition at line 316 of file thread_safe_container.h.
| using kcenon::container::snapshot_reader::snapshot_ptr = std::shared_ptr<const thread_safe_container::value_map> |
Definition at line 318 of file thread_safe_container.h.
|
inlineexplicit |
Definition at line 320 of file thread_safe_container.h.
References update_snapshot().

|
inline |
Get value from snapshot (lock-protected read of snapshot)
| T | The expected type (must be a valid variant type) |
Definition at line 331 of file thread_safe_container.h.
References snapshot_, and snapshot_mutex_.
| void kcenon::container::snapshot_reader::update_snapshot | ( | ) |
Update snapshot from container.
Definition at line 352 of file thread_safe_container.cpp.
References container_, snapshot_, and snapshot_mutex_.
Referenced by snapshot_reader().

|
private |
Definition at line 349 of file thread_safe_container.h.
Referenced by update_snapshot().
|
private |
Definition at line 350 of file thread_safe_container.h.
Referenced by get(), and update_snapshot().
|
mutableprivate |
Definition at line 351 of file thread_safe_container.h.
Referenced by get(), and update_snapshot().