#include <borrow.h>
Public Member Functions | |
~BorrowedPointer () | |
Release the lock on destruction. | |
template<typename G , typename L > | |
BorrowedPointer (BorrowedPointer< G, L > &&other) | |
template<typename G , typename L > | |
BorrowedPointer & | operator= (BorrowedPointer< G, L > &&other) |
BorrowedPointer (const BorrowedPointer &)=delete | |
BorrowedPointer & | operator= (const BorrowedPointer &)=delete |
GuardedType * | operator-> () |
Provides access to the borrowed object's members. | |
const GuardedType * | operator-> () const |
Const overload. | |
GuardedType & | operator* () |
const GuardedType & | operator* () const |
Const overload. | |
Friends | |
template<typename , typename > | |
class | Borrowable |
Allow BorrowedPointer creation inside of Borrowable's acquire methods. | |
template<typename , typename > | |
class | BorrowedPointer |
The BorrowedPointer
is an RAII handle which wraps a pointer to a borrowed object along with a held lock which is guarding the object. When destroyed, the lock is released.
|
inline |
Move-constructs a BorrowedPointer<T>
from a BorrowedPointer<U>
.
This allows not only pure move construction where GuardedType == G
and Lock == L
, but also converting construction where GuardedType
is a base class of OtherType
and Lock
is a base class of OtherLock
, like `BorrowedPointer<Base> base_ptr(derived_borrowable.acquire());
Postcondition: The other BorrowedPointer is no longer valid and will assert if the GuardedType is accessed.
|
inline |
Provides access to the borrowed object directly.
embed:rst:leading-asterisk * .. note:: * The member of pointer member access operator, ``operator->()``, is * recommended over this API as this is prone to leaking references. * However, this is sometimes necessary. * * .. warning: * Be careful not to leak references to the borrowed object! *
|
inline |
Move-assigns a BorrowedPointer<T>
from a BorrowedPointer<U>
.
This allows not only pure move construction where GuardedType == OtherType
and Lock == OtherLock
, but also converting construction where GuardedType
is a base class of OtherType
and Lock
is a base class of OtherLock
, like `BorrowedPointer<Base> base_ptr = derived_borrowable.acquire();
Postcondition: The other BorrowedPointer is no longer valid and will assert if the GuardedType is accessed.
|
friend |
Allow converting move constructor and assignment to access fields of this class.