ReXGlue SDK
Loading...
Searching...
No Matches
rex::kernel::PublishedPtr< T > Class Template Reference

#include <rex/kernel/object/object.h>

Public Member Functions

 PublishedPtr (std::unique_ptr< T > owner)
PublishedPtr & operator= (std::unique_ptr< T > owner)
T * get () noexcept
const T * get () const noexcept
T * operator-> () noexcept
const T * operator-> () const noexcept
 operator bool () const noexcept
void Replace (std::unique_ptr< T > next)
std::unique_ptr< T > Take () noexcept

Friends

bool operator== (const PublishedPtr &value, std::nullptr_t) noexcept

Detailed Description

template<typename T>
class rex::kernel::PublishedPtr< T >

Owns a host primitive that any thread reads without a lock and one writer at a time can replace. A replaced primitive stays alive until the owner is destroyed, so a reader holding the old pointer stays valid.

Template Parameters
TA primitive type with a virtual destructor.

Constructor & Destructor Documentation

◆ PublishedPtr()

template<typename T>
rex::kernel::PublishedPtr< T >::PublishedPtr ( std::unique_ptr< T > owner)
inline
Parameters
ownerThe primitive to publish.

Member Function Documentation

◆ get()

template<typename T>
T * rex::kernel::PublishedPtr< T >::get ( )
inlinenoexcept
Returns
The published primitive, which readers load once and then use.

◆ Replace()

template<typename T>
void rex::kernel::PublishedPtr< T >::Replace ( std::unique_ptr< T > next)
inline

Publishes a primitive and keeps the previous one alive. Callers serialize the writes.

Parameters
nextThe primitive readers load from now on.

◆ Take()

template<typename T>
std::unique_ptr< T > rex::kernel::PublishedPtr< T >::Take ( )
inlinenodiscardnoexcept

Takes the primitive of an object no other thread can see yet.

Returns
The primitive, which this pointer no longer publishes.

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