System io guard
This commit is contained in:
parent
f942d90515
commit
a974d2ac50
2 changed files with 13 additions and 10 deletions
|
|
@ -32,7 +32,8 @@ std::string nano::error_system_messages::message (int ev) const
|
||||||
*/
|
*/
|
||||||
|
|
||||||
nano::test::system::system () :
|
nano::test::system::system () :
|
||||||
io_ctx{ std::make_shared<boost::asio::io_context> () }
|
io_ctx{ std::make_shared<boost::asio::io_context> () },
|
||||||
|
io_guard{ boost::asio::make_work_guard (*io_ctx) }
|
||||||
{
|
{
|
||||||
auto scale_str = std::getenv ("DEADLINE_SCALE_FACTOR");
|
auto scale_str = std::getenv ("DEADLINE_SCALE_FACTOR");
|
||||||
if (scale_str)
|
if (scale_str)
|
||||||
|
|
@ -70,6 +71,16 @@ nano::test::system::~system ()
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void nano::test::system::stop ()
|
||||||
|
{
|
||||||
|
io_guard.reset ();
|
||||||
|
for (auto & node : nodes)
|
||||||
|
{
|
||||||
|
node->stop ();
|
||||||
|
}
|
||||||
|
work.stop ();
|
||||||
|
}
|
||||||
|
|
||||||
nano::node & nano::test::system::node (std::size_t index) const
|
nano::node & nano::test::system::node (std::size_t index) const
|
||||||
{
|
{
|
||||||
debug_assert (index < nodes.size ());
|
debug_assert (index < nodes.size ());
|
||||||
|
|
@ -574,15 +585,6 @@ void nano::test::system::generate_mass_activity (uint32_t count_a, nano::node &
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void nano::test::system::stop ()
|
|
||||||
{
|
|
||||||
for (auto i : nodes)
|
|
||||||
{
|
|
||||||
i->stop ();
|
|
||||||
}
|
|
||||||
work.stop ();
|
|
||||||
}
|
|
||||||
|
|
||||||
nano::node_config nano::test::system::default_config ()
|
nano::node_config nano::test::system::default_config ()
|
||||||
{
|
{
|
||||||
nano::node_config config{ get_available_port () };
|
nano::node_config config{ get_available_port () };
|
||||||
|
|
|
||||||
|
|
@ -75,6 +75,7 @@ namespace test
|
||||||
|
|
||||||
public:
|
public:
|
||||||
std::shared_ptr<boost::asio::io_context> io_ctx;
|
std::shared_ptr<boost::asio::io_context> io_ctx;
|
||||||
|
boost::asio::executor_work_guard<boost::asio::io_context::executor_type> io_guard;
|
||||||
std::vector<std::shared_ptr<nano::node>> nodes;
|
std::vector<std::shared_ptr<nano::node>> nodes;
|
||||||
nano::stats stats;
|
nano::stats stats;
|
||||||
nano::logger logger{ "tests" };
|
nano::logger logger{ "tests" };
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue