template<class T, class TLock>
nCine::LockedPtr class

Pointer wrapper that keeps the object locked for the duration of its existence.

Holds a raw pointer together with a std::unique_lock over a lockable of type TLock. The lock is acquired before the wrapper is constructed and released when it is destroyed, so the pointed-to object can be accessed safely through operator*() and operator->() for the lifetime of the wrapper.

Constructors, destructors, conversion operators

LockedPtr(T* ptr, std::unique_lock<TLock>&& lock) explicit noexcept
operator bool() const explicit noexcept
Whether the pointer is assigned.

Public functions

auto get() const -> T* constexpr noexcept
Returns the pointer.
auto operator*() const -> T& constexpr noexcept
Dereferences the pointer.
auto operator->() const -> T* constexpr noexcept
Allows direct calls against the pointer.