mirror of
https://github.com/Xahau/xahaud.git
synced 2025-12-06 17:27:52 +00:00
Fix gentex usage in nudb
This commit is contained in:
committed by
Tom Ritchford
parent
d537ceedd6
commit
2cccd8ab28
@@ -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 <class _>
|
||||
void
|
||||
gentex_t<_>::lock()
|
||||
gentex_t<_>::start()
|
||||
{
|
||||
std::lock_guard<
|
||||
std::mutex> l(m_);
|
||||
@@ -73,7 +73,7 @@ gentex_t<_>::lock()
|
||||
|
||||
template <class _>
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -841,6 +841,7 @@ store<Hasher, Codec, File>::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<Hasher, Codec, File>::commit()
|
||||
w.flush();
|
||||
s_->lf.sync();
|
||||
}
|
||||
// VFALCO Audit for concurrency
|
||||
{
|
||||
std::lock_guard<gentex> 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();
|
||||
|
||||
Reference in New Issue
Block a user