You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@kvrocks.apache.org by GitBox <gi...@apache.org> on 2022/05/14 15:17:48 UTC

[GitHub] [incubator-kvrocks] torwig commented on a diff in pull request #577: Add LMove command

torwig commented on code in PR #577:
URL: https://github.com/apache/incubator-kvrocks/pull/577#discussion_r872992590


##########
src/lock_manager.cc:
##########
@@ -51,3 +51,7 @@ void LockManager::Lock(const rocksdb::Slice &key) {
 void LockManager::UnLock(const rocksdb::Slice &key) {
   mutex_pool_[hash(key)]->unlock();
 }
+
+void LockManager::LockTwo(const rocksdb::Slice &first_key, const rocksdb::Slice &second_key) {
+  std::lock(*mutex_pool_[hash(first_key)], *mutex_pool_[hash(second_key)]);

Review Comment:
   In my implementation, if the source and destination are the same LockManager::LockTwo won't be called. Instead, only one mutex will be locked via LockGuard. Additionally, `TwoLockGuard` or `LockTwo()` can be modified to check whether two keys are equal and make a proper lock. 
   Yes, I was thinking about multi-lock, but there are 2 points:
   - is it possible that more than 2 locks should be locked?
   - multi-version should deal with templates :)



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@kvrocks.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org