Atomic signal source.
More...
#include <ion/signal.hpp>
|
| | SignalSource (ValueType initial=ValueType{}) noexcept |
| | Construct signal source.
|
| |
|
| SignalSource (SignalSource const &)=delete |
| | SignalSource requires stable address so copy and move operations are disabled.
|
| |
|
SignalSource & | operator= (SignalSource const &)=delete |
| |
| auto | Load () const noexcept -> ValueType |
| | Load signal value.
|
| |
| void | Store (ValueType value) noexcept |
| | Store signal value.
|
| |
| auto | CompareExchangeWeak (ValueType &expected, ValueType desired) noexcept -> bool |
| | Set signal value using read-modify-write semantics.
|
| |
| auto | CompareExchangeStrong (ValueType &expected, ValueType desired) noexcept -> bool |
| | Set signal value using read-modify-write semantics.
|
| |
|
(Note that these are not member symbols.)
|
| template<class T, class UnaryOperation> |
| auto | CompareExchangeTransform (SignalSource< T > &signal, UnaryOperation op) noexcept -> T |
| | Performs atomic compare-exchange transformation of signal value.
|
| |
template<class T>
class ion::SignalSource< T >
Atomic signal source.
See Signals for example.
- Template Parameters
-
| T | Value type of atomic signal. Must be trivial type and std::atomic<T>::is_always_lock_free == true. |
- Thread Safety
- thread-safe
◆ SignalSource()
Construct signal source.
- Parameters
-
◆ CompareExchangeStrong()
template<class T>
| auto ion::SignalSource< T >::CompareExchangeStrong |
( |
ValueType & | expected, |
|
|
ValueType | desired ) -> bool |
|
nodiscardnoexcept |
Set signal value using read-modify-write semantics.
- Parameters
-
| [in,out] | expected | Reference to value expected to be found in the signal. This value is updated if the bitwise comparison failed. |
| [in] | desired | Desired value to write. |
- Returns
- true if exchange was made.
-
false otherwise.
- Memory Order
- Relaxed memory order without any synchronization.
- See also
- CompareExchangeTransform()
◆ CompareExchangeWeak()
template<class T>
| auto ion::SignalSource< T >::CompareExchangeWeak |
( |
ValueType & | expected, |
|
|
ValueType | desired ) -> bool |
|
nodiscardnoexcept |
Set signal value using read-modify-write semantics.
- Note
- Weak version is allowed to spuriously fail which will yield better performance on some platforms.
- Parameters
-
| [in,out] | expected | Reference to value expected to be found in the signal. This value is updated if the bitwise comparison failed. |
| [in] | desired | Value to write if expected value comparison succeeds. |
- Returns
- true if exchange was made.
-
false otherwise.
- Memory Order
- Relaxed memory order without any synchronization.
- See also
- CompareExchangeTransform()
◆ Load()
Load signal value.
- Returns
- current value.
- Memory Order
- Relaxed memory order without any synchronization.
◆ Store()
Store signal value.
- Parameters
-
- Memory Order
- Relaxed memory order without any synchronization.