ezEngine Release 26.3
Loading...
Searching...
No Matches
ezLockedObject< T, O > Class Template Reference

RAII wrapper providing thread-safe access to an object with automatic lock management. More...

#include <LockedObject.h>

Public Member Functions

EZ_ALWAYS_INLINE ezLockedObject (T &ref_lock, O *pObject)
 
EZ_ALWAYS_INLINE ezLockedObject (ezLockedObject< T, O > &&rhs)
 
 ezLockedObject (const ezLockedObject< T, O > &rhs)=delete
 
void operator= (const ezLockedObject< T, O > &&rhs)
 
void operator= (const ezLockedObject< T, O > &rhs)=delete
 
EZ_ALWAYS_INLINE bool isValid () const
 Whether the encapsulated object exists at all or is nullptr.
 
O * Borrow ()
 
const O * Borrow () const
 
O * operator-> ()
 
const O * operator-> () const
 
O & operator* ()
 
const O & operator* () const
 
bool operator== (const O *rhs) const
 
bool operator!= (const O *rhs) const
 
bool operator! () const
 
 operator bool () const
 

Detailed Description

template<typename T, typename O>
class ezLockedObject< T, O >

RAII wrapper providing thread-safe access to an object with automatic lock management.

Combines object access with lock acquisition/release in a single type. The lock is acquired in the constructor and automatically released in the destructor, ensuring exception-safe critical sections. Only move semantics are supported to prevent accidental lock duplication.

Template parameters:

  • T: Lock type (e.g., ezMutex, ezSharedMutex)
  • O: Object type being protected

Typical usage involves creating this as a temporary object to access shared data safely.


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