|
RAVENNAKIT
|
This class provides a real-time safe way to share objects among a single reader. More...
#include <realtime_shared_object.hpp>
Classes | |
| class | RealtimeAccessGuard |
| A guard object provides access to the value. More... | |
Public Member Functions | |
| RealtimeSharedObject ()=default | |
| Default constructor. | |
| RealtimeSharedObject (T initial_value) | |
| ~RealtimeSharedObject () | |
| RealtimeSharedObject (const RealtimeSharedObject &)=delete | |
| RealtimeSharedObject & | operator= (const RealtimeSharedObject &)=delete |
| RealtimeSharedObject (RealtimeSharedObject &&)=delete | |
| RealtimeSharedObject & | operator= (RealtimeSharedObject &&)=delete |
| RealtimeAccessGuard | access_realtime () |
| std::optional< T > | update (T value) |
| Swaps current value by given value by placing the new value into the active slot, and then swapping the pointer for the realtime thread. | |
| bool | reset () |
| Resets the object to contain a new, default constructed object. | |
Static Public Attributes | |
| static constexpr size_t | k_loop_upper_bound = 1'000'000 |
| The max number of tries before giving up (preventing runaway code). | |
| static constexpr uint32_t | k_yield_threshold = 10 |
| The number of iterations after which a function will start yielding. | |
| static constexpr uint32_t | k_sleep_threshold = 10'000 |
| The number of iterations after which a function will start sleeping. | |
This class provides a real-time safe way to share objects among a single reader.
The writer side is protected by a mutex. Internally a double buffer and CAS loop is used to update the value in a thread-safe manner.
| T | The type of the object to share. |
Definition at line 41 of file realtime_shared_object.hpp.
|
default |
Default constructor.
|
inlineexplicit |
| initial_value | Initial value to set. |
Definition at line 137 of file realtime_shared_object.hpp.
|
inline |
Definition at line 139 of file realtime_shared_object.hpp.
|
delete |
|
delete |
|
inlinenodiscard |
Definition at line 154 of file realtime_shared_object.hpp.
|
delete |
|
delete |
|
inlinenodiscard |
Resets the object to contain a new, default constructed object.
Definition at line 192 of file realtime_shared_object.hpp.
|
inlinenodiscard |
Swaps current value by given value by placing the new value into the active slot, and then swapping the pointer for the realtime thread.
| value | The new value to share with the realtime thread. |
Definition at line 164 of file realtime_shared_object.hpp.
|
staticconstexpr |
The max number of tries before giving up (preventing runaway code).
Definition at line 44 of file realtime_shared_object.hpp.
|
staticconstexpr |
The number of iterations after which a function will start sleeping.
Definition at line 50 of file realtime_shared_object.hpp.
|
staticconstexpr |
The number of iterations after which a function will start yielding.
Definition at line 47 of file realtime_shared_object.hpp.