diff --git a/src/blobstore/implementations/onblocks/datatreestore/DataTree.cpp b/src/blobstore/implementations/onblocks/datatreestore/DataTree.cpp index 682ff062..e74e4edd 100644 --- a/src/blobstore/implementations/onblocks/datatreestore/DataTree.cpp +++ b/src/blobstore/implementations/onblocks/datatreestore/DataTree.cpp @@ -159,7 +159,8 @@ uint32_t DataTree::_numLeaves(const DataNode &node) const { void DataTree::traverseLeaves(uint32_t beginIndex, uint32_t endIndex, function func) { //TODO Can we traverse in parallel? - unique_lock lock(_mutex); //TODO Only lock when resizing. Otherwise parallel read/write to a blob is not possible! + boost::upgrade_lock lock(_mutex); //TODO Rethink locking here. We probably need locking when the traverse resizes the blob. Otherwise, parallel traverse should be possible. We already allow it below by freeing the upgrade_lock, but we currently only allow it if ALL traverses are entirely inside the valid region. Can we allow more parallelity? + auto exclusiveLock = std::make_unique>(lock); ASSERT(beginIndex <= endIndex, "Invalid parameters"); if (0 == endIndex) { // In this case the utils::ceilLog(_, endIndex) below would fail @@ -195,6 +196,7 @@ void DataTree::traverseLeaves(uint32_t beginIndex, uint32_t endIndex, function