#include <inline_borrowable.h>
Public Member Functions | |
constexpr | InlineBorrowable () |
Construct the guarded object and lock using their default constructors. | |
template<typename... Args> | |
constexpr | InlineBorrowable (std::in_place_t, Args &&... args) |
template<typename... ObjectArgs, typename... LockArgs> | |
constexpr | InlineBorrowable (std::tuple< ObjectArgs... > &&object_args, std::tuple< LockArgs... > &&lock_args=std::make_tuple()) |
template<typename ObjectConstructor , typename LockConstructor = Lock(), typename = std::enable_if_t< std::is_invocable_r_v<GuardedType&&, ObjectConstructor>>, typename = std::enable_if_t< std::is_invocable_r_v<Lock&&, LockConstructor>>> | |
constexpr | InlineBorrowable (const ObjectConstructor &object_ctor, const LockConstructor &lock_ctor=internal::DefaultConstruct< Lock >) |
template<typename ObjectConstructor , typename LockConstructor = Lock(), typename = std::enable_if_t< std::is_invocable_r_v<GuardedType&&, ObjectConstructor>>, typename = std::enable_if_t< std::is_invocable_r_v<Lock&&, LockConstructor>>> | |
constexpr | InlineBorrowable (ObjectConstructor &object_ctor, const LockConstructor &lock_ctor=internal::DefaultConstruct< Lock >) |
template<typename ObjectConstructor , typename LockConstructor = Lock(), typename = std::enable_if_t< std::is_invocable_r_v<GuardedType&&, ObjectConstructor>>, typename = std::enable_if_t< std::is_invocable_r_v<Lock&&, LockConstructor>>> | |
constexpr | InlineBorrowable (const ObjectConstructor &object_ctor, LockConstructor &lock_ctor) |
template<typename ObjectConstructor , typename LockConstructor = Lock(), typename = std::enable_if_t< std::is_invocable_r_v<GuardedType&&, ObjectConstructor>>, typename = std::enable_if_t< std::is_invocable_r_v<Lock&&, LockConstructor>>> | |
constexpr | InlineBorrowable (ObjectConstructor &object_ctor, LockConstructor &lock_ctor) |
![]() | |
constexpr | Borrowable (GuardedType &object, LockType &lock) noexcept |
template<typename U > | |
constexpr | Borrowable (const Borrowable< U, LockType > &other) |
Borrowable (const Borrowable &)=default | |
Borrowable & | operator= (const Borrowable &)=default |
Borrowable (Borrowable &&other)=default | |
Borrowable & | operator= (Borrowable &&other)=default |
BorrowedPointer< GuardedType, LockType > | acquire () const |
Blocks indefinitely until the object can be borrowed. Failures are fatal. | |
template<int &... ExplicitArgumentBarrier, typename T = LockType, typename = std::enable_if_t<is_lockable_v<T>>> | |
std::optional< BorrowedPointer< GuardedType, LockType > > | try_acquire () const |
InlineBorrowable
holds an object of GuardedType
and a Lock that guards access to the object. It should be used when an object should be guarded for its entire lifecycle by a single lock.
This object should be shared with other componetns as a reference of type Borrowable<GuardedType, LockInterface>
.
|
inlineexplicitconstexpr |
Construct the guarded object by providing its constructor arguments inline. The lock is constructed using its default constructor.
This constructor supports list initialization for arrays, structs, and other objects such as std::array
.
Example:
|
inlineexplicitconstexpr |
Construct the guarded object and lock by providing their construction parameters using separate tuples. The 2nd tuple can be ommitted to construct the lock using its default constructor.
Example:
|
inlineexplicitconstexpr |
Construct the guarded object and lock by providing factory functions. The 2nd callable can be ommitted to construct the lock using its default constructor.
Example: