You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@quickstep.apache.org by na...@apache.org on 2016/06/11 03:18:35 UTC

incubator-quickstep git commit: Move createNewBlock() out of the critical section in getBlockForInsertion

Repository: incubator-quickstep
Updated Branches:
  refs/heads/fix_getblockforinsertion [created] 688d37aae


Move createNewBlock() out of the critical section in getBlockForInsertion


Project: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/commit/688d37aa
Tree: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/tree/688d37aa
Diff: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/diff/688d37aa

Branch: refs/heads/fix_getblockforinsertion
Commit: 688d37aaead71415e70435ea708cff18596df874
Parents: ccd11c0
Author: Navneet Potti <na...@apache.org>
Authored: Fri Jun 10 22:18:03 2016 -0500
Committer: Navneet Potti <na...@apache.org>
Committed: Fri Jun 10 22:18:03 2016 -0500

----------------------------------------------------------------------
 storage/InsertDestination.cpp | 20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/688d37aa/storage/InsertDestination.cpp
----------------------------------------------------------------------
diff --git a/storage/InsertDestination.cpp b/storage/InsertDestination.cpp
index 354bed4..8969378 100644
--- a/storage/InsertDestination.cpp
+++ b/storage/InsertDestination.cpp
@@ -339,21 +339,21 @@ void BlockPoolInsertDestination::getPartiallyFilledBlocks(std::vector<MutableBlo
 }
 
 MutableBlockReference BlockPoolInsertDestination::getBlockForInsertion() {
-  SpinMutexLock lock(mutex_);
-  if (available_block_refs_.empty()) {
-    if (available_block_ids_.empty()) {
-      return createNewBlock();
-    } else {
+  {
+    SpinMutexLock lock(mutex_);
+    if (!available_block_refs_.empty()) {
+      MutableBlockReference retval = std::move(available_block_refs_.back());
+      available_block_refs_.pop_back();
+      return retval;
+    }
+    else if (!available_block_ids_.empty()) {
       const block_id id = available_block_ids_.back();
       available_block_ids_.pop_back();
       MutableBlockReference retval = storage_manager_->getBlockMutable(id, relation_);
       return retval;
     }
-  } else {
-    MutableBlockReference retval = std::move(available_block_refs_.back());
-    available_block_refs_.pop_back();
-    return retval;
-  }
+  } // release mutex_ lock
+  return createNewBlock();
 }
 
 void BlockPoolInsertDestination::returnBlock(MutableBlockReference &&block, const bool full) {