kudu-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From t...@apache.org
Subject [3/3] incubator-kudu git commit: lock_manager: change from emulated-move to C++11 move
Date Mon, 22 Feb 2016 23:53:08 GMT
lock_manager: change from emulated-move to C++11 move

Change-Id: I35b06fdfd52006731b5a20b1e15704ab9967385e
Reviewed-on: http://gerrit.cloudera.org:8080/2244
Tested-by: Kudu Jenkins
Reviewed-by: Dan Burkert <dan@cloudera.com>


Project: http://git-wip-us.apache.org/repos/asf/incubator-kudu/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-kudu/commit/7b157c5c
Tree: http://git-wip-us.apache.org/repos/asf/incubator-kudu/tree/7b157c5c
Diff: http://git-wip-us.apache.org/repos/asf/incubator-kudu/diff/7b157c5c

Branch: refs/heads/master
Commit: 7b157c5c1b494de41cfbabd35f44eff2bf4bf8c8
Parents: 6737d78
Author: Todd Lipcon <todd@apache.org>
Authored: Thu Feb 18 21:19:44 2016 -0800
Committer: Todd Lipcon <todd@apache.org>
Committed: Mon Feb 22 23:52:16 2016 +0000

----------------------------------------------------------------------
 src/kudu/tablet/lock_manager-test.cc |  2 +-
 src/kudu/tablet/lock_manager.cc      |  8 ++++----
 src/kudu/tablet/lock_manager.h       | 21 ++++++++++-----------
 src/kudu/tablet/tablet.cc            |  9 ++++-----
 4 files changed, 19 insertions(+), 21 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-kudu/blob/7b157c5c/src/kudu/tablet/lock_manager-test.cc
----------------------------------------------------------------------
diff --git a/src/kudu/tablet/lock_manager-test.cc b/src/kudu/tablet/lock_manager-test.cc
index 28a7a35..4fa098c 100644
--- a/src/kudu/tablet/lock_manager-test.cc
+++ b/src/kudu/tablet/lock_manager-test.cc
@@ -99,7 +99,7 @@ TEST_F(LockManagerTest, TestMoveLock) {
   ASSERT_TRUE(row_lock.acquired());
 
   // Move it to a new instance.
-  ScopedRowLock moved_lock(row_lock.Pass());
+  ScopedRowLock moved_lock(std::move(row_lock));
   ASSERT_TRUE(moved_lock.acquired());
   ASSERT_FALSE(row_lock.acquired());
 }

http://git-wip-us.apache.org/repos/asf/incubator-kudu/blob/7b157c5c/src/kudu/tablet/lock_manager.cc
----------------------------------------------------------------------
diff --git a/src/kudu/tablet/lock_manager.cc b/src/kudu/tablet/lock_manager.cc
index 0f17dfc..d83005f 100644
--- a/src/kudu/tablet/lock_manager.cc
+++ b/src/kudu/tablet/lock_manager.cc
@@ -278,12 +278,12 @@ ScopedRowLock::ScopedRowLock(LockManager *manager,
   }
 }
 
-ScopedRowLock::ScopedRowLock(RValue other) {
-  TakeState(other.object);
+ScopedRowLock::ScopedRowLock(ScopedRowLock&& other) {
+  TakeState(&other);
 }
 
-ScopedRowLock& ScopedRowLock::operator=(RValue other) {
-  TakeState(other.object);
+ScopedRowLock& ScopedRowLock::operator=(ScopedRowLock&& other) {
+  TakeState(&other);
   return *this;
 }
 

http://git-wip-us.apache.org/repos/asf/incubator-kudu/blob/7b157c5c/src/kudu/tablet/lock_manager.h
----------------------------------------------------------------------
diff --git a/src/kudu/tablet/lock_manager.h b/src/kudu/tablet/lock_manager.h
index 6bfaa67..731a897 100644
--- a/src/kudu/tablet/lock_manager.h
+++ b/src/kudu/tablet/lock_manager.h
@@ -73,26 +73,25 @@ class LockManager {
 //   }
 //   // lock is released when the object exits its scope.
 //
-// This class emulates C++11 move constructors and thus can be
-// copied by using the special '.Pass()' function. For example:
+// This class implements C++11 move constructors and thus can be
+// transferred around using std::move(). For example:
 //
 // void DoSomething(ScopedRowLock l) {
 //   // l owns the lock and will release at the end of this function
 // }
 // ScopedRowLock my_lock(&manager, ...);
-// DoSomething(l.Pass());
-// CHECK(!l.acquired()); // doesn't own lock anymore, since it Pass()ed
+// DoSomething(std::move(l);
+// CHECK(!l.acquired()); // doesn't own lock anymore, since it moved
 class ScopedRowLock {
-  MOVE_ONLY_TYPE_FOR_CPP_03(ScopedRowLock, RValue);
  public:
 
   // Construct an initially-unlocked lock holder.
   // You can later assign this to actually hold a lock using
-  // the emulated move-constructor:
+  // the move-constructor:
   //   ScopedRowLock l;
-  //   l = ScopedRowLock(...); // use the ctor below
+  //   l = ScopedRowLock(...);
   // or
-  //   l = other_row_lock.Pass();
+  //   l = std::move(other_row_lock);
   ScopedRowLock()
     : manager_(NULL),
       acquired_(false),
@@ -104,9 +103,9 @@ class ScopedRowLock {
   ScopedRowLock(LockManager *manager, const TransactionState* ctx,
                 const Slice &key, LockManager::LockMode mode);
 
-  // Emulated Move constructor
-  ScopedRowLock(RValue other); // NOLINT(runtime/explicit)
-  ScopedRowLock& operator=(RValue other);
+  // Move constructor and assignment.
+  ScopedRowLock(ScopedRowLock&& other);
+  ScopedRowLock& operator=(ScopedRowLock&& other);
 
   void Release();
 

http://git-wip-us.apache.org/repos/asf/incubator-kudu/blob/7b157c5c/src/kudu/tablet/tablet.cc
----------------------------------------------------------------------
diff --git a/src/kudu/tablet/tablet.cc b/src/kudu/tablet/tablet.cc
index 88f8417..c2cb4a2 100644
--- a/src/kudu/tablet/tablet.cc
+++ b/src/kudu/tablet/tablet.cc
@@ -327,11 +327,10 @@ Status Tablet::AcquireLockForOp(WriteTransactionState* tx_state, RowOp*
op) {
   op->key_probe.reset(new tablet::RowSetKeyProbe(row_key));
   RETURN_NOT_OK(CheckRowInTablet(row_key));
 
-  ScopedRowLock row_lock(&lock_manager_,
-                         tx_state,
-                         op->key_probe->encoded_key_slice(),
-                         LockManager::LOCK_EXCLUSIVE);
-  op->row_lock = row_lock.Pass();
+  op->row_lock = ScopedRowLock(&lock_manager_,
+                               tx_state,
+                               op->key_probe->encoded_key_slice(),
+                               LockManager::LOCK_EXCLUSIVE);
   return Status::OK();
 }
 


Mime
View raw message