Autonomy Software C++ 24.5.1
Welcome to the Autonomy Software repository of the Mars Rover Design Team (MRDT) at Missouri University of Science and Technology (Missouri S&T)! API reference contains the source code and other resources for the development of the autonomy software for our Mars rover. The Autonomy Software project aims to compete in the University Rover Challenge (URC) by demonstrating advanced autonomous capabilities and robust navigation algorithms.
Loading...
Searching...
No Matches
duckdb::StorageLockInternals Struct Reference
Inheritance diagram for duckdb::StorageLockInternals:
Collaboration diagram for duckdb::StorageLockInternals:

Public Member Functions

unique_ptr< StorageLockKey > GetExclusiveLock ()
unique_ptr< StorageLockKey > GetSharedLock ()
unique_ptr< StorageLockKey > TryGetExclusiveLock ()
unique_ptr< StorageLockKey > TryUpgradeCheckpointLock (StorageLockKey &lock)
void ReleaseExclusiveLock ()
void ReleaseSharedLock ()
Public Member Functions inherited from duckdb::enable_shared_from_this< StorageLockInternals >
shared_ptr< StorageLockInternals > shared_from_this ()

Public Attributes

mutex exclusive_lock
atomic< idx_t > read_count

Additional Inherited Members

Protected Member Functions inherited from duckdb::enable_shared_from_this< StorageLockInternals >
enable_shared_from_this & operator= (enable_shared_from_this const &) noexcept

Constructor & Destructor Documentation

◆ StorageLockInternals()

duckdb::StorageLockInternals::StorageLockInternals ( )
inline
426087 : read_count(0) {
426088 }

Member Function Documentation

◆ GetExclusiveLock()

unique_ptr< StorageLockKey > duckdb::StorageLockInternals::GetExclusiveLock ( )
inline
426094 {
426095 exclusive_lock.lock();
426096 while (read_count != 0) {
426097 }
426098 return make_uniq<StorageLockKey>(shared_from_this(), StorageLockType::EXCLUSIVE);
426099 }

◆ GetSharedLock()

unique_ptr< StorageLockKey > duckdb::StorageLockInternals::GetSharedLock ( )
inline
426101 {
426102 exclusive_lock.lock();
426103 read_count++;
426104 exclusive_lock.unlock();
426105 return make_uniq<StorageLockKey>(shared_from_this(), StorageLockType::SHARED);
426106 }

◆ TryGetExclusiveLock()

unique_ptr< StorageLockKey > duckdb::StorageLockInternals::TryGetExclusiveLock ( )
inline
426108 {
426109 if (!exclusive_lock.try_lock()) {
426110 // could not lock mutex
426111 return nullptr;
426112 }
426113 if (read_count != 0) {
426114 // there are active readers - cannot get exclusive lock
426115 exclusive_lock.unlock();
426116 return nullptr;
426117 }
426118 // success!
426119 return make_uniq<StorageLockKey>(shared_from_this(), StorageLockType::EXCLUSIVE);
426120 }

◆ TryUpgradeCheckpointLock()

unique_ptr< StorageLockKey > duckdb::StorageLockInternals::TryUpgradeCheckpointLock ( StorageLockKey & lock)
inline
426122 {
426123 if (lock.GetType() != StorageLockType::SHARED) {
426124 throw InternalException("StorageLock::TryUpgradeLock called on an exclusive lock");
426125 }
426126 if (!exclusive_lock.try_lock()) {
426127 // could not lock mutex
426128 return nullptr;
426129 }
426130 if (read_count != 1) {
426131 // other shared locks are active: failed to upgrade
426132 D_ASSERT(read_count != 0);
426133 exclusive_lock.unlock();
426134 return nullptr;
426135 }
426136 // no other shared locks active: success!
426137 return make_uniq<StorageLockKey>(shared_from_this(), StorageLockType::EXCLUSIVE);
426138 }

◆ ReleaseExclusiveLock()

void duckdb::StorageLockInternals::ReleaseExclusiveLock ( )
inline
426140 {
426141 exclusive_lock.unlock();
426142 }

◆ ReleaseSharedLock()

void duckdb::StorageLockInternals::ReleaseSharedLock ( )
inline
426143 {
426144 read_count--;
426145 }

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