boolLockManager::LockShared(Transaction *txn, const RID &rid){ // Note that: READ UNCOMMITTED no S-Lock. /** * 1. Checking txn state. Txn should abort if its state isn't growing. * 2. Append lock request to this RID request queue. If the rid exist X-Lock previous, * then txn blocked(lock_table_[rid].cv_.wait()). Otherwise S-Lock can granted. * 3. The S-Lock request is granted. */ } boolLockManager::LockExclusive(Transaction *txn, const RID &rid){ // Note that: READ UNCOMMITTED no S-Lock. /** * 1. Checking txn state. Txn should abort if its state isn't growing. * 2. Append lock request to this RID request queue. If the rid exist S/X-Lock previous, * then txn blocked. Otherwise X-Lock can granted. * 3. X-Lock can be acquired only if txn in front of queue. Otherwise, it will be blocked. * 4. the X-Lock request is granted. */ } boolLockManager::LockUpgrade(Transaction *txn, const RID &rid){ /** * 1.1 Checking txn state. Txn should abort if txn's state isn't growing. * 1.2 Whether another txn already ready upgrading. * 2. find correct postion to upgrade S-Lock to X-Lock * 3. Update txn request lock message. */ } boolLockManager::Unlock(Transaction *txn, const RID &rid){ /** * 1. If txn doesn't have any this tuple lock, then return false. * 2. Delete this txn in request queue, and release tuple lock hold by txn. * 3. txn's state is growing when txn release lock, then set txn state is shrinking, * so txn can't acquire any lock. Note that: it is used in REPEATABLE READS isolation level */ }