kudu-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From t...@apache.org
Subject [2/6] kudu git commit: log_block_manager: replace custom RAII class with ScopedCleanup
Date Sun, 14 Aug 2016 22:34:25 GMT
log_block_manager: replace custom RAII class with ScopedCleanup

Change-Id: I810626472adffdeafa626db3f4fc927b7c2a0b86
Reviewed-on: http://gerrit.cloudera.org:8080/3965
Tested-by: Kudu Jenkins
Reviewed-by: Adar Dembo <adar@cloudera.com>


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

Branch: refs/heads/master
Commit: 9d897e692620a3272a03c63336190cf5a09f739b
Parents: 3cec55a
Author: Todd Lipcon <todd@apache.org>
Authored: Fri Aug 12 20:01:04 2016 -0700
Committer: Todd Lipcon <todd@apache.org>
Committed: Sun Aug 14 22:33:10 2016 +0000

----------------------------------------------------------------------
 src/kudu/fs/log_block_manager.cc | 20 ++++----------------
 1 file changed, 4 insertions(+), 16 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/kudu/blob/9d897e69/src/kudu/fs/log_block_manager.cc
----------------------------------------------------------------------
diff --git a/src/kudu/fs/log_block_manager.cc b/src/kudu/fs/log_block_manager.cc
index df9b3f5..dfeb454 100644
--- a/src/kudu/fs/log_block_manager.cc
+++ b/src/kudu/fs/log_block_manager.cc
@@ -280,20 +280,6 @@ class LogBlockContainer {
   const std::string& root_path() const { return root_path_; }
 
  private:
-  // RAII-style class for finishing containers in FinishBlock().
-  class ScopedFinisher {
-   public:
-    // 'container' must outlive the finisher.
-    explicit ScopedFinisher(LogBlockContainer* container) :
-      container_(container) {
-    }
-    ~ScopedFinisher() {
-      container_->block_manager()->MakeContainerAvailable(container_);
-    }
-   private:
-    LogBlockContainer* container_;
-  };
-
   LogBlockContainer(LogBlockManager* block_manager, PathInstanceMetadataPB* instance,
                     std::string root_path, std::string path,
                     gscoped_ptr<WritablePBContainerFile> metadata_writer,
@@ -516,9 +502,11 @@ void LogBlockContainer::CheckBlockRecord(const BlockRecordPB& record,
 }
 
 Status LogBlockContainer::FinishBlock(const Status& s, WritableBlock* block) {
-  ScopedFinisher finisher(this);
+  auto cleanup = MakeScopedCleanup([&]() {
+      block_manager_->MakeContainerAvailable(this);
+    });
   if (!s.ok()) {
-    // Early return; 'finisher' makes the container available again.
+    // Early return; 'cleanup' makes the container available again.
     return s;
   }
 


Mime
View raw message