pub struct ThreadLocker { /* private fields */ }Expand description
A thread-based locker that shares locks with other ThreadLockers on the same thread.
ThreadLocker extends BasicLocker to track which thread created it. All ThreadLockers on the same thread share locks with each other, which allows multiple cursors to operate without lock conflicts.
This is used for auto-commit operations where a transaction context is not explicitly provided.
Implementations§
Source§impl ThreadLocker
impl ThreadLocker
Sourcepub fn new(id: i64, lock_manager: Arc<LockManager>) -> Self
pub fn new(id: i64, lock_manager: Arc<LockManager>) -> Self
Creates a new ThreadLocker for the current thread.
Registers this locker’s thread ID in the LockManager’s sharing registry
so that LockImpl::try_lock() can bypass conflict detection for co-owning
ThreadLockers on the same thread.
§Arguments
id- Unique locker IDlock_manager- Shared lock manager
Sourcepub fn with_timeout(
id: i64,
lock_manager: Arc<LockManager>,
timeout_ms: u64,
) -> Self
pub fn with_timeout( id: i64, lock_manager: Arc<LockManager>, timeout_ms: u64, ) -> Self
Creates a ThreadLocker with a specified timeout.
Sourcepub fn get_thread_id(&self) -> u64
pub fn get_thread_id(&self) -> u64
Returns the thread ID that created this locker.
Sourcepub fn release_all_locks(&mut self) -> Result<(), TxnError>
pub fn release_all_locks(&mut self) -> Result<(), TxnError>
Release all locks held by this locker.
Sourcepub fn set_lock_timeout(&mut self, timeout_ms: u64)
pub fn set_lock_timeout(&mut self, timeout_ms: u64)
Sets the lock timeout.
Trait Implementations§
Source§impl Drop for ThreadLocker
impl Drop for ThreadLocker
Source§impl Locker for ThreadLocker
impl Locker for ThreadLocker
Returns true if the other locker was created on the same thread.
Both lockers must be ThreadLockers and have the same originating thread for sharing. We check via the LockManager’s sharing registry (locker_id → thread_id).