|
Container System 0.1.0
High-performance C++20 type-safe container framework with SIMD-accelerated serialization
|
Auto-refreshing lock-free reader. More...
#include <thread_safe_container.h>

Public Member Functions | |
| auto_refresh_reader (std::shared_ptr< thread_safe_container > container, std::chrono::milliseconds refresh_interval) | |
| Construct auto-refresh reader. | |
| ~auto_refresh_reader () | |
| Destructor - stops the refresh thread. | |
| auto_refresh_reader (const auto_refresh_reader &)=delete | |
| auto_refresh_reader & | operator= (const auto_refresh_reader &)=delete |
| auto_refresh_reader (auto_refresh_reader &&)=delete | |
| auto_refresh_reader & | operator= (auto_refresh_reader &&)=delete |
| void | stop () |
| Stop the auto-refresh thread. | |
| bool | is_running () const noexcept |
| Check if auto-refresh is running. | |
| std::chrono::milliseconds | refresh_interval () const noexcept |
| Get the refresh interval. | |
| template<concepts::ValueVariantType T> | |
| std::optional< T > | get (std::string_view key) const noexcept |
| Lock-free typed value read. | |
| bool | contains (std::string_view key) const noexcept |
| Lock-free value existence check. | |
| size_t | size () const noexcept |
| Lock-free snapshot size check. | |
| bool | empty () const noexcept |
| Lock-free empty check. | |
| std::vector< std::string > | keys () const |
| Get all keys from snapshot. | |
| template<typename Func > | |
| void | for_each (Func &&func) const |
| Iterate over snapshot. | |
| void | refresh () |
| Manual refresh (in addition to automatic) | |
| size_t | refresh_count () const noexcept |
| Get the number of refreshes performed. | |
| std::shared_ptr< lockfree_container_reader > | reader () const noexcept |
| Get the underlying lock-free reader. | |
| std::shared_ptr< thread_safe_container > | source () const noexcept |
| Get the source container. | |
Private Member Functions | |
| void | refresh_loop () |
Private Attributes | |
| std::shared_ptr< lockfree_container_reader > | reader_ |
| std::chrono::milliseconds | refresh_interval_ |
| std::thread | refresh_thread_ |
| std::mutex | mutex_ |
| std::condition_variable | cv_ |
| bool | running_ |
Auto-refreshing lock-free reader.
This class wraps a lockfree_container_reader and automatically refreshes its snapshot at a configurable interval using a background thread. All read operations are delegated to the underlying lock-free reader.
Properties:
Definition at line 615 of file thread_safe_container.h.
|
inlineexplicit |
Construct auto-refresh reader.
| container | The thread-safe container to read from |
| refresh_interval | The interval between automatic refreshes |
Definition at line 622 of file thread_safe_container.h.
References refresh_loop(), and refresh_thread_.

|
inline |
Destructor - stops the refresh thread.
Definition at line 634 of file thread_safe_container.h.
References stop().

|
delete |
|
delete |
|
inlinenodiscardnoexcept |
Lock-free value existence check.
| key | The key to check |
Definition at line 702 of file thread_safe_container.h.
References reader_.
|
inlinenodiscardnoexcept |
Lock-free empty check.
Definition at line 718 of file thread_safe_container.h.
References reader_.
|
inline |
Iterate over snapshot.
| Func | Callback function type |
| func | Callback to apply to each key-value pair |
Definition at line 736 of file thread_safe_container.h.
References reader_.
|
inlinenodiscardnoexcept |
Lock-free typed value read.
Delegates to the underlying lockfree_container_reader.
| T | The expected value type |
| key | The key to look up |
Definition at line 693 of file thread_safe_container.h.
References reader_.
|
inlinenodiscardnoexcept |
Check if auto-refresh is running.
Definition at line 670 of file thread_safe_container.h.
|
inlinenodiscard |
Get all keys from snapshot.
Definition at line 726 of file thread_safe_container.h.
References reader_.
|
delete |
|
delete |
|
inlinenodiscardnoexcept |
Get the underlying lock-free reader.
Definition at line 761 of file thread_safe_container.h.
References reader_.
|
inline |
Manual refresh (in addition to automatic)
Forces an immediate refresh of the snapshot.
Definition at line 745 of file thread_safe_container.h.
References reader_.
|
inlinenodiscardnoexcept |
Get the number of refreshes performed.
Definition at line 753 of file thread_safe_container.h.
References reader_.
|
inlinenodiscardnoexcept |
Get the refresh interval.
Definition at line 679 of file thread_safe_container.h.
References refresh_interval_.
|
inlineprivate |
Definition at line 774 of file thread_safe_container.h.
References cv_, mutex_, reader_, and refresh_interval_.
Referenced by auto_refresh_reader().

|
inlinenodiscardnoexcept |
Lock-free snapshot size check.
Definition at line 710 of file thread_safe_container.h.
References reader_.
|
inlinenodiscardnoexcept |
Get the source container.
Definition at line 769 of file thread_safe_container.h.
References reader_.
|
inline |
Stop the auto-refresh thread.
After calling stop(), no more automatic refreshes will occur. Manual refresh() calls are still possible.
Definition at line 652 of file thread_safe_container.h.
References cv_, mutex_, refresh_thread_, and running_.
Referenced by ~auto_refresh_reader().

|
private |
Definition at line 789 of file thread_safe_container.h.
Referenced by refresh_loop(), and stop().
|
mutableprivate |
Definition at line 788 of file thread_safe_container.h.
Referenced by is_running(), refresh_loop(), and stop().
|
private |
Definition at line 785 of file thread_safe_container.h.
Referenced by contains(), empty(), for_each(), get(), keys(), reader(), refresh(), refresh_count(), refresh_loop(), size(), and source().
|
private |
Definition at line 786 of file thread_safe_container.h.
Referenced by refresh_interval(), and refresh_loop().
|
private |
Definition at line 787 of file thread_safe_container.h.
Referenced by auto_refresh_reader(), and stop().
|
private |
Definition at line 790 of file thread_safe_container.h.
Referenced by is_running(), and stop().