BehaviorTree
Core Library to create and execute Behavior Trees
Loading...
Searching...
No Matches
BT::LockedPtr< T > Class Template Reference

The LockedPtr class is used to share a pointer to an object and a mutex that protects the read/write access to that object. More...

#include <locked_reference.hpp>

Public Member Functions

 LockedPtr (T *obj, std::mutex *obj_mutex)
 
 LockedPtr (LockedPtr const &)=delete
 
LockedPtr & operator= (LockedPtr const &)=delete
 
 LockedPtr (LockedPtr &&other) noexcept
 
LockedPtr & operator= (LockedPtr &&other) noexcept
 
 operator bool () const
 
void lock ()
 
void unlock ()
 
const T * get () const
 
const T * operator-> () const
 
T * operator-> ()
 
template<typename OtherT >
void assign (const OtherT &other)
 

Detailed Description

template<typename T>
class BT::LockedPtr< T >

The LockedPtr class is used to share a pointer to an object and a mutex that protects the read/write access to that object.

As long as the object remains in scope, the mutex is locked, therefore you must destroy this instance as soon as the pointer was used.

LockedPtr does not own the object it points to: the owner is only expected to keep it alive while the mutex is locked. In particular, the pointer must not be considered valid after calling unlock().


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