summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--netfs/fuse/fuseFiles.cpp22
1 files changed, 13 insertions, 9 deletions
diff --git a/netfs/fuse/fuseFiles.cpp b/netfs/fuse/fuseFiles.cpp
index eeb5423..7cc6413 100644
--- a/netfs/fuse/fuseFiles.cpp
+++ b/netfs/fuse/fuseFiles.cpp
@@ -123,23 +123,27 @@ namespace NetFS {
while (true) {
std::unique_lock lock(of->mutex);
// Acquire operations to wait for
- auto R = of->bg.equal_range(key);
+ const auto R = of->bg.equal_range(key);
if (R.first == R.second) {
// Perform operation
return f(key);
}
else {
- std::vector<std::shared_ptr<OpenFile::WriteState>> overlap;
- overlap.reserve(safe {std::distance(R.first, R.second)});
- for (auto i = R.first; i != R.second; i++) {
- overlap.push_back(i->second);
- }
+ const auto overlap = std::transform_reduce(
+ R.first, R.second, std::vector<std::shared_future<void>> {},
+ [](auto && v, auto && i) {
+ v.push_back(i);
+ return std::forward<decltype(v)>(v);
+ },
+ [](auto && i) {
+ return i.second->future;
+ });
// Wait for them whilst unlocked
lock.release()->unlock();
try {
- for (const auto & r : overlap) {
- r->future.get();
- }
+ std::for_each(overlap.begin(), overlap.end(), [](auto && r) {
+ r.get();
+ });
}
catch (const SystemError &) {
throw;