LMMS
Loading...
Searching...
No Matches
juce::Atomic< Type > Struct Template Referencefinal

#include <juce_Atomic.h>

Public Types

using DiffType = typename AtomicHelpers::DiffTypeHelper<Type>::Type

Public Member Functions

 Atomic () noexcept
 Atomic (Type initialValue) noexcept
 Atomic (const Atomic &other) noexcept
 ~Atomic () noexcept
Type get () const noexcept
void set (Type newValue) noexcept
Type exchange (Type newValue) noexcept
bool compareAndSetBool (Type newValue, Type valueToCompare) noexcept
Atomic< Type > & operator= (const Atomic &other) noexcept
Atomic< Type > & operator= (Type newValue) noexcept
Type operator+= (DiffType amountToAdd) noexcept
Type operator-= (DiffType amountToSubtract) noexcept
Type operator++ () noexcept
Type operator-- () noexcept
void memoryBarrier () noexcept
Type compareAndSetValue (Type, Type) noexcept

Public Attributes

std::atomic< Type > value

Detailed Description

template<typename Type>
struct juce::Atomic< Type >

A simple wrapper around std::atomic.

@tags{Core}

Member Typedef Documentation

◆ DiffType

template<typename Type>
using juce::Atomic< Type >::DiffType = typename AtomicHelpers::DiffTypeHelper<Type>::Type

Constructor & Destructor Documentation

◆ Atomic() [1/3]

template<typename Type>
juce::Atomic< Type >::Atomic ( )
inlinenoexcept

Creates a new value, initialised to zero.

◆ Atomic() [2/3]

template<typename Type>
juce::Atomic< Type >::Atomic ( Type initialValue)
inlinenoexcept

Creates a new value, with a given initial value.

◆ Atomic() [3/3]

template<typename Type>
juce::Atomic< Type >::Atomic ( const Atomic< Type > & other)
inlinenoexcept

Copies another value (atomically).

◆ ~Atomic()

template<typename Type>
juce::Atomic< Type >::~Atomic ( )
inlinenoexcept

Destructor.

Member Function Documentation

◆ compareAndSetBool()

template<typename Type>
bool juce::Atomic< Type >::compareAndSetBool ( Type newValue,
Type valueToCompare )
inlinenoexcept

Atomically compares this value with a target value, and if it is equal, sets this to be equal to a new value.

This operation is the atomic equivalent of doing this:

bool compareAndSetBool (Type newValue, Type valueToCompare)
{
if (get() == valueToCompare)
{
set (newValue);
return true;
}
return false;
}
Type get() const noexcept
Definition juce_Atomic.h:64
void set(Type newValue) noexcept
Definition juce_Atomic.h:67
bool compareAndSetBool(Type newValue, Type valueToCompare) noexcept
Definition juce_Atomic.h:96

Internally, this method calls std::atomic::compare_exchange_strong with memory_order_seq_cst (the strictest std::memory_order).

Returns
true if the comparison was true and the value was replaced; false if the comparison failed and the value was left unchanged.
See also
compareAndSetValue

◆ compareAndSetValue()

template<typename Type>
Type juce::Atomic< Type >::compareAndSetValue ( Type ,
Type  )
noexcept

◆ exchange()

template<typename Type>
Type juce::Atomic< Type >::exchange ( Type newValue)
inlinenoexcept

Atomically sets the current value, returning the value that was replaced.

◆ get()

template<typename Type>
Type juce::Atomic< Type >::get ( ) const
inlinenoexcept

Atomically reads and returns the current value.

◆ memoryBarrier()

template<typename Type>
void juce::Atomic< Type >::memoryBarrier ( )
inlinenoexcept

Implements a memory read/write barrier.

Internally this calls std::atomic_thread_fence with memory_order_seq_cst (the strictest std::memory_order).

◆ operator++()

template<typename Type>
Type juce::Atomic< Type >::operator++ ( )
inlinenoexcept

Atomically increments this value, returning the new value.

◆ operator+=()

template<typename Type>
Type juce::Atomic< Type >::operator+= ( DiffType amountToAdd)
inlinenoexcept

Atomically adds a number to this value, returning the new value.

◆ operator--()

template<typename Type>
Type juce::Atomic< Type >::operator-- ( )
inlinenoexcept

Atomically decrements this value, returning the new value.

◆ operator-=()

template<typename Type>
Type juce::Atomic< Type >::operator-= ( DiffType amountToSubtract)
inlinenoexcept

Atomically subtracts a number from this value, returning the new value.

◆ operator=() [1/2]

template<typename Type>
Atomic< Type > & juce::Atomic< Type >::operator= ( const Atomic< Type > & other)
inlinenoexcept

Copies another value into this one (atomically).

◆ operator=() [2/2]

template<typename Type>
Atomic< Type > & juce::Atomic< Type >::operator= ( Type newValue)
inlinenoexcept

Copies another value into this one (atomically).

◆ set()

template<typename Type>
void juce::Atomic< Type >::set ( Type newValue)
inlinenoexcept

Atomically sets the current value.

Member Data Documentation

◆ value

template<typename Type>
std::atomic<Type> juce::Atomic< Type >::value

The std::atomic object that this class operates on.


The documentation for this struct was generated from the following file: