diff --git a/src/beast/beast/nudb/detail/gentex.h b/src/beast/beast/nudb/detail/gentex.h index 649616ca2..b64da8088 100644 --- a/src/beast/beast/nudb/detail/gentex.h +++ b/src/beast/beast/nudb/detail/gentex.h @@ -48,10 +48,10 @@ public: gentex_t& operator= (gentex_t const&) = delete; void - lock(); + start(); void - unlock(); + finish(); std::size_t lock_gen(); @@ -62,7 +62,7 @@ public: template void -gentex_t<_>::lock() +gentex_t<_>::start() { std::lock_guard< std::mutex> l(m_); @@ -73,7 +73,7 @@ gentex_t<_>::lock() template void -gentex_t<_>::unlock() +gentex_t<_>::finish() { std::unique_lock< std::mutex> l(m_); @@ -106,7 +106,7 @@ gentex_t<_>::unlock_gen ( { --prev_; if (prev_ == 0) - cond_.notify_all(); + cond_.notify_all(); } } diff --git a/src/beast/beast/nudb/store.h b/src/beast/beast/nudb/store.h index e06c00828..dd8414e0f 100644 --- a/src/beast/beast/nudb/store.h +++ b/src/beast/beast/nudb/store.h @@ -841,6 +841,7 @@ store::commit() s_->p0.clear(); buckets_ = buckets; modulus_ = modulus; + g_.start(); } // Write clean buckets to log file // VFALCO Should the bulk_writer buffer size be tunable? @@ -861,14 +862,11 @@ store::commit() w.flush(); s_->lf.sync(); } - // VFALCO Audit for concurrency - { - std::lock_guard g (g_); - // Write new buckets to key file - for (auto const e : s_->c1) - e.second.write (s_->kf, - (e.first + 1) * s_->kh.block_size); - } + g_.finish(); + // Write new buckets to key file + for (auto const e : s_->c1) + e.second.write (s_->kf, + (e.first + 1) * s_->kh.block_size); // Finalize the commit s_->df.sync(); s_->kf.sync();