ion 0.12.0
Atomic concurrency support library
Loading...
Searching...
No Matches
ion::SignalSource< T > Class Template Reference

Atomic signal source. More...

#include <ion/signal.hpp>

Public Types

using ValueType = T
 

Public Member Functions

 SignalSource (ValueType initial=ValueType{}) noexcept
 Construct signal source.
 
 SignalSource (SignalSource const &)=delete
 SignalSource requires stable address so copy and move operations are disabled.
 
SignalSourceoperator= (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.
 

Related Symbols

(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.
 

Detailed Description

template<class T>
class ion::SignalSource< T >

Atomic signal source.

See Signals for example.

Template Parameters
TValue type of atomic signal. Must be trivial type and std::atomic<T>::is_always_lock_free == true.
Thread Safety
thread-safe

Constructor & Destructor Documentation

◆ SignalSource()

template<class T>
ion::SignalSource< T >::SignalSource ( ValueType initial = ValueType{})
explicitnoexcept

Construct signal source.

Parameters
initialInitial value.

Member Function Documentation

◆ 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]expectedReference to value expected to be found in the signal. This value is updated if the bitwise comparison failed.
[in]desiredDesired 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]expectedReference to value expected to be found in the signal. This value is updated if the bitwise comparison failed.
[in]desiredValue 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()

template<class T>
auto ion::SignalSource< T >::Load ( ) const -> ValueType
nodiscardnoexcept

Load signal value.

Returns
current value.
Memory Order
Relaxed memory order without any synchronization.

◆ Store()

template<class T>
void ion::SignalSource< T >::Store ( ValueType value)
noexcept

Store signal value.

Parameters
valueNew value to store.
Memory Order
Relaxed memory order without any synchronization.