diff --git a/nano/node/scheduler/priority.cpp b/nano/node/scheduler/priority.cpp index 0499fd2a..0ee92f46 100644 --- a/nano/node/scheduler/priority.cpp +++ b/nano/node/scheduler/priority.cpp @@ -1,9 +1,11 @@ #include +#include #include nano::scheduler::priority::priority (nano::node & node_a, nano::stats & stats_a) : node{ node_a }, - stats{ stats_a } + stats{ stats_a }, + buckets{ std::make_unique () } { } @@ -60,7 +62,7 @@ bool nano::scheduler::priority::activate (nano::account const & account_a, nano: auto balance = node.ledger.balance (transaction, hash); auto previous_balance = node.ledger.balance (transaction, conf_info.frontier); nano::lock_guard lock{ mutex }; - buckets.push (info->modified, block, std::max (balance, previous_balance)); + buckets->push (info->modified, block, std::max (balance, previous_balance)); notify (); return true; // Activated } @@ -77,12 +79,12 @@ void nano::scheduler::priority::notify () std::size_t nano::scheduler::priority::size () const { nano::lock_guard lock{ mutex }; - return buckets.size () + manual_queue.size (); + return buckets->size () + manual_queue.size (); } bool nano::scheduler::priority::empty_locked () const { - return buckets.empty () && manual_queue.empty (); + return buckets->empty () && manual_queue.empty (); } bool nano::scheduler::priority::empty () const @@ -93,12 +95,12 @@ bool nano::scheduler::priority::empty () const std::size_t nano::scheduler::priority::priority_queue_size () const { - return buckets.size (); + return buckets->size (); } bool nano::scheduler::priority::priority_queue_predicate () const { - return node.active.vacancy () > 0 && !buckets.empty (); + return node.active.vacancy () > 0 && !buckets->empty (); } bool nano::scheduler::priority::manual_queue_predicate () const @@ -133,8 +135,8 @@ void nano::scheduler::priority::run () } else if (priority_queue_predicate ()) { - auto block = buckets.top (); - buckets.pop (); + auto block = buckets->top (); + buckets->pop (); lock.unlock (); stats.inc (nano::stat::type::election_scheduler, nano::stat::detail::insert_priority); auto result = node.active.insert (block); @@ -163,6 +165,6 @@ std::unique_ptr nano::scheduler::priority::colle auto composite = std::make_unique (name); composite->add_component (std::make_unique (container_info{ "manual_queue", manual_queue.size (), sizeof (decltype (manual_queue)::value_type) })); - composite->add_component (buckets.collect_container_info ("buckets")); + composite->add_component (buckets->collect_container_info ("buckets")); return composite; } diff --git a/nano/node/scheduler/priority.hpp b/nano/node/scheduler/priority.hpp index a1d825d3..13582867 100644 --- a/nano/node/scheduler/priority.hpp +++ b/nano/node/scheduler/priority.hpp @@ -2,7 +2,6 @@ #include #include -#include #include @@ -19,6 +18,7 @@ class node; namespace nano::scheduler { +class buckets; class priority final { public: @@ -52,7 +52,7 @@ private: bool priority_queue_predicate () const; bool manual_queue_predicate () const; - nano::scheduler::buckets buckets; + std::unique_ptr buckets; std::deque, boost::optional, nano::election_behavior>> manual_queue; bool stopped{ false };