StormByte 3.0.0
C++26 foundation of the StormByte suite
Loading...
Searching...
No Matches
StormByte::Safe::AtomicShared< T > Class Template Reference

Atomic publication of a Shared. More...

#include <StormByte/safe/pointers.hxx>

Public Member Functions

 AtomicShared () noexcept
 Construct an empty atomic owner.
 AtomicShared (Shared< T > owner) noexcept
 Construct from an owner.
 AtomicShared (const AtomicShared &other)=delete
 Copy constructor.
 ~AtomicShared ()
 Destroy the published owner.
AtomicShared & operator= (const AtomicShared &other)=delete
 Copy assignment.
AtomicShared & operator= (Shared< T > owner) noexcept
 Publish an owner.
 operator bool () const noexcept
 Test whether an owner is published.
Shared< T > load () const noexcept
 Copy the published owner.
void store (Shared< T > owner) noexcept
 Replace the published owner.
Shared< T > exchange (Shared< T > owner) noexcept
 Replace the published owner and return the previous one.
bool compare_exchange_strong (Shared< T > &expected, Shared< T > desired) noexcept
 Replace the published owner when it compares equal by address.
bool compare_exchange_weak (Shared< T > &expected, Shared< T > desired) noexcept
 Replace the published owner when it compares equal by address.

Detailed Description

template<class T>
class StormByte::Safe::AtomicShared< T >

Atomic publication of a Shared.

Template Parameters
TPointee type.

Load, store, exchange and compare-exchange adjust the same Base control block. The lock lives in this object, so two modules can publish a Shared without a libc++ control block.

Constructor & Destructor Documentation

◆ AtomicShared() [1/3]

template<class T>
StormByte::Safe::AtomicShared< T >::AtomicShared ( )
noexcept

Construct an empty atomic owner.

◆ AtomicShared() [2/3]

template<class T>
StormByte::Safe::AtomicShared< T >::AtomicShared ( Shared< T > owner)
explicitnoexcept

Construct from an owner.

Parameters
ownerOwner to publish.

◆ AtomicShared() [3/3]

template<class T>
StormByte::Safe::AtomicShared< T >::AtomicShared ( const AtomicShared< T > & other)
delete

Copy constructor.

Deleted.

Parameters
otherIgnored.

◆ ~AtomicShared()

template<class T>
StormByte::Safe::AtomicShared< T >::~AtomicShared ( )

Destroy the published owner.

Member Function Documentation

◆ compare_exchange_strong()

template<class T>
bool StormByte::Safe::AtomicShared< T >::compare_exchange_strong ( Shared< T > & expected,
Shared< T > desired )
noexcept

Replace the published owner when it compares equal by address.

Parameters
expectedExpected owner. Replaced with the current owner when the exchange fails.
desiredOwner to publish.
Returns
Whether the exchange happened.

◆ compare_exchange_weak()

template<class T>
bool StormByte::Safe::AtomicShared< T >::compare_exchange_weak ( Shared< T > & expected,
Shared< T > desired )
noexcept

Replace the published owner when it compares equal by address.

Parameters
expectedExpected owner. Replaced with the current owner when the exchange fails.
desiredOwner to publish.
Returns
Whether the exchange happened. May fail spuriously.

◆ exchange()

template<class T>
Shared< T > StormByte::Safe::AtomicShared< T >::exchange ( Shared< T > owner)
noexcept

Replace the published owner and return the previous one.

Parameters
ownerOwner to publish.
Returns
Previous owner.

◆ load()

template<class T>
Shared< T > StormByte::Safe::AtomicShared< T >::load ( ) const
noexcept

Copy the published owner.

Returns
Owner sharing the published control block.

◆ operator bool()

template<class T>
StormByte::Safe::AtomicShared< T >::operator bool ( ) const
explicitnoexcept

Test whether an owner is published.

Returns
Whether the published pointer is non-null.

◆ operator=() [1/2]

template<class T>
AtomicShared & StormByte::Safe::AtomicShared< T >::operator= ( const AtomicShared< T > & other)
delete

Copy assignment.

Deleted.

Parameters
otherIgnored.
Returns
This atomic owner.

◆ operator=() [2/2]

template<class T>
AtomicShared & StormByte::Safe::AtomicShared< T >::operator= ( Shared< T > owner)
noexcept

Publish an owner.

Parameters
ownerOwner to publish.
Returns
This atomic owner.

◆ store()

template<class T>
void StormByte::Safe::AtomicShared< T >::store ( Shared< T > owner)
noexcept

Replace the published owner.

Parameters
ownerOwner to publish.

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