Merge pull request #4556 from clemahieu/vote_generator_write_queue
This commit is contained in:
commit
06ef24b196
3 changed files with 5 additions and 6 deletions
|
@ -94,6 +94,7 @@ void nano::vote_generator::process_batch (std::deque<queue_entry_t> & batch)
|
|||
{
|
||||
std::deque<candidate_t> candidates_new;
|
||||
{
|
||||
auto guard = ledger.store.write_queue.wait (is_final ? nano::store::writer::voting_final : nano::store::writer::voting);
|
||||
auto transaction = ledger.store.tx_begin_write ({ tables::final_votes });
|
||||
|
||||
for (auto & [root, hash] : batch)
|
||||
|
|
|
@ -73,18 +73,14 @@ nano::store::write_guard nano::store::write_queue::wait (writer writer)
|
|||
}
|
||||
|
||||
nano::unique_lock<nano::mutex> lk (mutex);
|
||||
debug_assert (std::none_of (queue.cbegin (), queue.cend (), [writer] (auto const & item) { return item == writer; }));
|
||||
// Add writer to the end of the queue if it's not already waiting
|
||||
auto exists = std::find (queue.cbegin (), queue.cend (), writer) != queue.cend ();
|
||||
if (!exists)
|
||||
{
|
||||
queue.push_back (writer);
|
||||
}
|
||||
|
||||
while (queue.front () != writer)
|
||||
{
|
||||
cv.wait (lk);
|
||||
}
|
||||
|
||||
cv.wait (lk, [&] () { return queue.front () == writer; });
|
||||
return write_guard (guard_finish_callback);
|
||||
}
|
||||
|
||||
|
|
|
@ -14,6 +14,8 @@ enum class writer
|
|||
confirmation_height,
|
||||
process_batch,
|
||||
pruning,
|
||||
voting,
|
||||
voting_final,
|
||||
testing // Used in tests to emulate a write lock
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue