git-hulk commented on code in PR #577:
URL: https://github.com/apache/incubator-kvrocks/pull/577#discussion_r873640031


##########
src/lock_manager.h:
##########
@@ -55,3 +58,25 @@ class LockGuard {
   LockManager *lock_mgr_ = nullptr;
   rocksdb::Slice key_;
 };
+
+class MultiLockGuard {
+ public:
+  explicit MultiLockGuard(LockManager *lock_mgr, const 
std::vector<std::string> &keys):
+      lock_mgr_(lock_mgr) {
+    locks_ = lock_mgr_->MultiGet(keys);
+    for (const auto &iter : locks_) {
+      iter->lock();
+    }
+  }
+
+  ~MultiLockGuard() {
+    // Lock with order `A B C` and unlock should be `C B A`

Review Comment:
   Yes, for the `MultiLockGuary`, it's NOT different, but I think it's a good 
habit the lock and unlock with the reverse order.



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to