Pigweed
 
Loading...
Searching...
No Matches
pw::sync::TimedBorrowable< GuardedType, LockType > Class Template Reference

#include <timed_borrow.h>

Inheritance diagram for pw::sync::TimedBorrowable< GuardedType, LockType >:
pw::sync::Borrowable< GuardedType, LockType >

Public Member Functions

constexpr TimedBorrowable (GuardedType &object, LockType &lock) noexcept
 
template<typename U >
constexpr TimedBorrowable (const Borrowable< U, LockType > &other)
 
std::optional< BorrowedPointer< GuardedType, LockType > > try_acquire_for (chrono::SystemClock::duration timeout) const
 
std::optional< BorrowedPointer< GuardedType, LockType > > try_acquire_until (chrono::SystemClock::time_point deadline) const
 
- Public Member Functions inherited from pw::sync::Borrowable< GuardedType, LockType >
constexpr Borrowable (GuardedType &object, LockType &lock) noexcept
 
template<typename U >
constexpr Borrowable (const Borrowable< U, LockType > &other)
 
 Borrowable (const Borrowable &)=default
 
Borrowableoperator= (const Borrowable &)=default
 
 Borrowable (Borrowable &&other)=default
 
Borrowableoperator= (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
 

Detailed Description

template<typename GuardedType, typename LockType = pw::sync::VirtualBasicLockable>
class pw::sync::TimedBorrowable< GuardedType, LockType >

TimedBorrowable extends Borrowable with additional methods to borrow an object guarded by a lock that implements the TimedLockable C++ named requirement.

Member Function Documentation

◆ try_acquire_for()

template<typename GuardedType , typename LockType = pw::sync::VirtualBasicLockable>
std::optional< BorrowedPointer< GuardedType, LockType > > pw::sync::TimedBorrowable< GuardedType, LockType >::try_acquire_for ( chrono::SystemClock::duration  timeout) const
inline

Tries to borrow the object. Blocks until the specified timeout has elapsed or the object has been borrowed, whichever comes first. Returns a BorrowedPointer on success, otherwise std::nullopt (nothing).

◆ try_acquire_until()

template<typename GuardedType , typename LockType = pw::sync::VirtualBasicLockable>
std::optional< BorrowedPointer< GuardedType, LockType > > pw::sync::TimedBorrowable< GuardedType, LockType >::try_acquire_until ( chrono::SystemClock::time_point  deadline) const
inline

Tries to borrow the object. Blocks until the specified deadline has passed or the object has been borrowed, whichever comes first. Returns a BorrowedPointer on success, otherwise std::nullopt (nothing).


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