ion 0.12.0
Atomic concurrency support library
Loading...
Searching...
No Matches
signal.hpp File Reference

ion::{SignalSource, SignalToken} and algorithms More...

#include <atomic>
#include <cassert>
#include <cstdint>
#include <optional>
#include <tuple>
#include <type_traits>
#include <ion/detail/macros.hpp>

Go to the source code of this file.

Classes

class  ion::SignalSource< T >
 Atomic signal source. More...
 
class  ion::SignalToken< T >
 Signal token that has an associated SignalSource and last known value. More...
 
struct  ion::Status< T >
 Represents signal source previous (old) and current (new) value. More...
 
struct  ion::WaitAnyResult< T1, T2 >
 Represents wait result from one of multiple possible signals. More...
 
struct  ion::StatusTag
 Select algorithm overload that returns signal status. More...
 
struct  ion::DifferenceTag
 Select algorithm overload that returns signal difference. More...
 

Functions

template<class T, class UnaryOperation>
auto ion::CompareExchangeTransform (SignalSource< T > &signal, UnaryOperation op) noexcept -> T
 Performs atomic compare-exchange transformation of signal value.
 
template<class T>
constexpr auto ion::operator== (SignalToken< T > const &lhs, SignalToken< T > const &rhs) noexcept -> bool
 Equality comparison.
 
template<class T>
constexpr auto ion::operator!= (SignalToken< T > const &lhs, SignalToken< T > const &rhs) noexcept -> bool
 Inequality comparison.
 
Wait and yield current signal value.
template<class T>
auto ion::Wait (SignalToken< T > &token) noexcept -> T
 Wait until signal source changes and return current value.
 
template<class T, class Predicate>
auto ion::Wait (SignalToken< T > &token, Predicate &&stop_waiting) noexcept -> T
 Wait with predicate.
 
Wait and yield Status<T>.
template<class T>
auto ion::Wait (StatusTag, SignalToken< T > &token) noexcept -> Status< T >
 Wait until signal source changes and return current and previous values.
 
template<class T, class Predicate>
auto ion::Wait (StatusTag, SignalToken< T > &token, Predicate &&stop_waiting) noexcept -> Status< T >
 Wait with predicate.
 
Wait and yield changes since last.
template<class T>
auto ion::Wait (DifferenceTag, SignalToken< T > &token) noexcept -> T
 Wait until signal source changes and return difference (current - previous) value.
 
template<class T, class Predicate>
auto ion::Wait (DifferenceTag, SignalToken< T > &token, Predicate &&stop_waiting) noexcept -> T
 Wait until signal source changes and return difference (current - previous) value.
 
Wait for either of two signals.

Effects Load and compare each of the signals with previous value.

The first one to change will be recorded in the WaitAnyResult::index. Depending on the selected overload the result of WaitAnyResult::result is either the current, difference or the Status containing both previous and current value.

template<class T1, class T2>
auto ion::WaitAny (SignalToken< T1 > &token1, SignalToken< T2 > &token2) noexcept -> WaitAnyResult< T1, T2 >
 Wait for either of two signals to change.
 
template<class T1, class T2>
auto ion::WaitAny (StatusTag, SignalToken< T1 > &token1, SignalToken< T2 > &token2) noexcept -> WaitAnyResult< Status< T1 >, Status< T2 > >
 Wait for either of two signals to change.
 
template<class T1, class T2>
auto ion::WaitAny (DifferenceTag, SignalToken< T1 > &token1, SignalToken< T2 > &token2) noexcept -> WaitAnyResult< T1, T2 >
 Wait for either of two signals to change.
 

Variables

Tag-invoke types
constexpr StatusTag ion::status_tag {}
 Constant instance of StatusTag.
 
constexpr DifferenceTag ion::difference_tag {}
 Constant instance of DifferenceTag.
 

Detailed Description

ion::{SignalSource, SignalToken} and algorithms

SPDX-License-Identifier: LGPL-3.0-only