diff --git a/nano/node/node.cpp b/nano/node/node.cpp index bb9d064e0a..3b0130ab35 100644 --- a/nano/node/node.cpp +++ b/nano/node/node.cpp @@ -571,7 +571,7 @@ std::unique_ptr nano::collect_container_info (no composite->add_component (collect_container_info (node.confirmation_height_processor, "confirmation_height_processor")); composite->add_component (collect_container_info (node.distributed_work, "distributed_work")); composite->add_component (collect_container_info (node.aggregator, "request_aggregator")); - composite->add_component (node.scheduler.collect_container_info ("election_scheduler")); + composite->add_component (node.scheduler.collect_container_info ().to_legacy_component ("election_scheduler")); composite->add_component (node.vote_cache.collect_container_info ("vote_cache")); composite->add_component (collect_container_info (node.generator, "vote_generator")); composite->add_component (collect_container_info (node.final_generator, "vote_generator_final")); diff --git a/nano/node/scheduler/buckets.cpp b/nano/node/scheduler/buckets.cpp index c033f6f6ca..8e3dd1b968 100644 --- a/nano/node/scheduler/buckets.cpp +++ b/nano/node/scheduler/buckets.cpp @@ -138,13 +138,13 @@ void nano::scheduler::buckets::dump () const std::cerr << "current: " << current - buckets_m.begin () << '\n'; } -std::unique_ptr nano::scheduler::buckets::collect_container_info (std::string const & name) +nano::experimental::container_info nano::scheduler::buckets::collect_container_info () const { - auto composite = std::make_unique (name); + nano::experimental::container_info info; for (auto i = 0; i < buckets_m.size (); ++i) { auto const & bucket = buckets_m[i]; - composite->add_component (std::make_unique (container_info{ std::to_string (i), bucket->size (), 0 })); + info.put (std::to_string (i), bucket->size ()); } - return composite; + return info; } diff --git a/nano/node/scheduler/buckets.hpp b/nano/node/scheduler/buckets.hpp index 967b4408f7..6c94858670 100644 --- a/nano/node/scheduler/buckets.hpp +++ b/nano/node/scheduler/buckets.hpp @@ -55,6 +55,6 @@ class buckets final void dump () const; std::size_t index (nano::uint128_t const & balance) const; - std::unique_ptr collect_container_info (std::string const &); + nano::experimental::container_info collect_container_info () const; }; } // namespace nano::scheduler diff --git a/nano/node/scheduler/component.cpp b/nano/node/scheduler/component.cpp index 2108c683bb..983baee7c2 100644 --- a/nano/node/scheduler/component.cpp +++ b/nano/node/scheduler/component.cpp @@ -37,14 +37,10 @@ void nano::scheduler::component::stop () priority.stop (); } -std::unique_ptr nano::scheduler::component::collect_container_info (std::string const & name) +nano::experimental::container_info nano::scheduler::component::collect_container_info () const { - nano::unique_lock lock{ mutex }; - - auto composite = std::make_unique (name); - //composite->add_component (hinted.collect_container_info ("hinted")); - composite->add_component (manual.collect_container_info ("manual")); - //composite->add_component (optimistic.collect_container_info ("optimistic")); - composite->add_component (priority.collect_container_info ("priority")); - return composite; + nano::experimental::container_info info; + info.add ("manual", manual.collect_container_info ()); + info.add ("priority", priority.collect_container_info ()); + return info; } diff --git a/nano/node/scheduler/component.hpp b/nano/node/scheduler/component.hpp index 257902438a..0551240eb6 100644 --- a/nano/node/scheduler/component.hpp +++ b/nano/node/scheduler/component.hpp @@ -1,5 +1,6 @@ #pragma once +#include #include #include @@ -7,7 +8,6 @@ namespace nano { -class container_info_component; class node; } namespace nano::scheduler @@ -23,7 +23,6 @@ class component final std::unique_ptr manual_impl; std::unique_ptr optimistic_impl; std::unique_ptr priority_impl; - nano::mutex mutex; public: explicit component (nano::node & node); @@ -34,8 +33,9 @@ class component final // Stops all schedulers void stop (); - std::unique_ptr collect_container_info (std::string const & name); + nano::experimental::container_info collect_container_info () const; +public: nano::scheduler::hinted & hinted; nano::scheduler::manual & manual; nano::scheduler::optimistic & optimistic; diff --git a/nano/node/scheduler/manual.cpp b/nano/node/scheduler/manual.cpp index d409824559..e3e8398eec 100644 --- a/nano/node/scheduler/manual.cpp +++ b/nano/node/scheduler/manual.cpp @@ -84,11 +84,11 @@ void nano::scheduler::manual::run () } } -std::unique_ptr nano::scheduler::manual::collect_container_info (std::string const & name) +nano::experimental::container_info nano::scheduler::manual::collect_container_info () const { nano::unique_lock lock{ mutex }; - auto composite = std::make_unique (name); - composite->add_component (std::make_unique (container_info{ "queue", queue.size (), sizeof (decltype (queue)::value_type) })); - return composite; -} + nano::experimental::container_info info; + info.put ("queue", queue); + return info; +} \ No newline at end of file diff --git a/nano/node/scheduler/manual.hpp b/nano/node/scheduler/manual.hpp index 3edfa1dc75..c35522ca85 100644 --- a/nano/node/scheduler/manual.hpp +++ b/nano/node/scheduler/manual.hpp @@ -22,7 +22,7 @@ class manual final { std::deque, boost::optional, nano::election_behavior>> queue; nano::node & node; - nano::mutex mutex; + mutable nano::mutex mutex; nano::condition_variable condition; bool stopped{ false }; std::thread thread; @@ -41,6 +41,6 @@ class manual final // Call action with confirmed block, may be different than what we started with void push (std::shared_ptr const &, boost::optional const & = boost::none, nano::election_behavior = nano::election_behavior::normal); - std::unique_ptr collect_container_info (std::string const & name); + nano::experimental::container_info collect_container_info () const; }; // class manual } // nano::scheduler diff --git a/nano/node/scheduler/priority.cpp b/nano/node/scheduler/priority.cpp index c75c5b0976..fca4d5b5ac 100644 --- a/nano/node/scheduler/priority.cpp +++ b/nano/node/scheduler/priority.cpp @@ -130,11 +130,11 @@ void nano::scheduler::priority::run () } } -std::unique_ptr nano::scheduler::priority::collect_container_info (std::string const & name) +nano::experimental::container_info nano::scheduler::priority::collect_container_info () const { nano::unique_lock lock{ mutex }; - auto composite = std::make_unique (name); - composite->add_component (buckets->collect_container_info ("buckets")); - return composite; -} + nano::experimental::container_info info; + info.add ("buckets", buckets->collect_container_info ()); + return info; +} \ No newline at end of file diff --git a/nano/node/scheduler/priority.hpp b/nano/node/scheduler/priority.hpp index e232b3d971..69f14f2aee 100644 --- a/nano/node/scheduler/priority.hpp +++ b/nano/node/scheduler/priority.hpp @@ -39,7 +39,7 @@ class priority final std::size_t size () const; bool empty () const; - std::unique_ptr collect_container_info (std::string const & name); + nano::experimental::container_info collect_container_info () const; private: // Dependencies nano::node & node;