template<typename T, typename Lock>
cubos::core::memory::ReadGuard class

Provides safe read-only access to an object using a lock.

Template parameters
T Guarded object type.
Lock Held lock type.

This class was created because there are multiple parts of the code that need to provide access to objects in a thread-safe manner.

Usage example

using AssetMetaRead = core::memory::ReadGuard<AssetMeta, std::shared_lock<std::shared_mutex>>;

Constructors, destructors, conversion operators

ReadGuard(const T& object, Lock&& lock)
Constructor.
ReadGuard(ReadGuard&& other) noexcept
Move constructor.

Public functions

auto get() const -> const T&
Gets a reference to the underlying object.
auto operator*() const -> const T&
Gets a reference to the underlying object.
auto operator->() const -> const T*
Gets a pointer to the underlying object.

Function documentation

template<typename T, typename Lock>
cubos::core::memory::ReadGuard<T, Lock>::ReadGuard(const T& object, Lock&& lock)

Constructor.

Parameters
object Object to guard.
lock Lock to hold.

template<typename T, typename Lock>
cubos::core::memory::ReadGuard<T, Lock>::ReadGuard(ReadGuard&& other) noexcept

Move constructor.

Parameters
other Guard to move from.

template<typename T, typename Lock>
const T& cubos::core::memory::ReadGuard<T, Lock>::get() const

Gets a reference to the underlying object.

Returns Underlying object.

template<typename T, typename Lock>
const T& cubos::core::memory::ReadGuard<T, Lock>::operator*() const

Gets a reference to the underlying object.

Returns Underlying object.

template<typename T, typename Lock>
const T* cubos::core::memory::ReadGuard<T, Lock>::operator->() const

Gets a pointer to the underlying object.

Returns Underlying object.