|
| | ObservableValue (std::convertible_to< T > auto &&value) |
| | Constructs ObservableValue with initial atomic value.
|
|
| ObservableValue () |
| | Constructs ObservableValue with default initial value.
|
|
| ObservableValue (ObservableValue const &)=delete |
|
| ObservableValue (ObservableValue &&)=default |
|
ObservableValue & | operator= (ObservableValue const &)=delete |
|
ObservableValue & | operator= (ObservableValue &&)=default |
| ObservableValue & | operator= (std::convertible_to< T > auto &&val) |
| | Assignment operator that updates atomic value and notifies observers.
|
| T | get () const |
| | Gets the current atomic value.
|
| | operator T () const |
| | Implicit conversion to the current atomic value.
|
| void | set (std::convertible_to< T > auto &&val) |
| | Sets a new atomic value and notifies observers if changed.
|
| void | forceNotify () override |
| | Forces notification of all observers with the current value.
|
| boost::signals2::connection | observe (std::invocable< T const & > auto &&fn) |
| | Registers an observer callback for value changes.
|
| bool | hasObservers () const |
| | Checks if there are any active observers.
|
template<Observable T>
class util::ObservableValue< std::atomic< T > >
Partial specialization of ObservableValue for atomic types.
This specialization provides thread-safe observation of atomic values while maintaining atomic semantics. It avoids the issues of copying atomic values and handles race conditions properly.
- Template Parameters
-
| T | The underlying type stored in the atomic |
- Thread Safety
- All operations are thread-safe
- Observer notifications are atomic with respect to value changes
- Multiple threads can safely modify and observe the atomic value
- Performance Considerations
- Uses atomic compare-and-swap operations for updates
- Minimizes atomic reads during guard operations
- Observer notifications happen outside of atomic operations when possible