Signal manager thread role (#4565)
This commit is contained in:
parent
2b6ee636ca
commit
2897be497e
4 changed files with 10 additions and 4 deletions
|
|
@ -1,4 +1,5 @@
|
||||||
#include <nano/lib/signal_manager.hpp>
|
#include <nano/lib/signal_manager.hpp>
|
||||||
|
#include <nano/lib/thread_roles.hpp>
|
||||||
#include <nano/lib/utility.hpp>
|
#include <nano/lib/utility.hpp>
|
||||||
|
|
||||||
#include <boost/asio.hpp>
|
#include <boost/asio.hpp>
|
||||||
|
|
@ -10,7 +11,8 @@
|
||||||
nano::signal_manager::signal_manager () :
|
nano::signal_manager::signal_manager () :
|
||||||
work (boost::asio::make_work_guard (ioc))
|
work (boost::asio::make_work_guard (ioc))
|
||||||
{
|
{
|
||||||
smthread = boost::thread ([&ioc = ioc] () {
|
thread = std::thread ([&ioc = ioc] () {
|
||||||
|
nano::thread_role::set (nano::thread_role::name::signal_manager);
|
||||||
ioc.run ();
|
ioc.run ();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
@ -21,7 +23,7 @@ nano::signal_manager::~signal_manager ()
|
||||||
/// io_context::run() function will exit once all other work has completed.
|
/// io_context::run() function will exit once all other work has completed.
|
||||||
work.reset ();
|
work.reset ();
|
||||||
ioc.stop ();
|
ioc.stop ();
|
||||||
smthread.join ();
|
thread.join ();
|
||||||
}
|
}
|
||||||
|
|
||||||
nano::signal_manager::signal_descriptor::signal_descriptor (std::shared_ptr<boost::asio::signal_set> sigset_a, signal_manager & sigman_a, std::function<void (int)> handler_func_a, bool repeat_a) :
|
nano::signal_manager::signal_descriptor::signal_descriptor (std::shared_ptr<boost::asio::signal_set> sigset_a, signal_manager & sigman_a, std::function<void (int)> handler_func_a, bool repeat_a) :
|
||||||
|
|
|
||||||
|
|
@ -4,11 +4,11 @@
|
||||||
|
|
||||||
#include <boost/asio.hpp>
|
#include <boost/asio.hpp>
|
||||||
#include <boost/system/error_code.hpp>
|
#include <boost/system/error_code.hpp>
|
||||||
#include <boost/thread.hpp>
|
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include <thread>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
namespace nano
|
namespace nano
|
||||||
|
|
@ -73,7 +73,7 @@ private:
|
||||||
std::vector<signal_descriptor> descriptor_list;
|
std::vector<signal_descriptor> descriptor_list;
|
||||||
|
|
||||||
/** thread to service the signal manager io context */
|
/** thread to service the signal manager io context */
|
||||||
boost::thread smthread;
|
std::thread thread;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -125,6 +125,9 @@ std::string nano::thread_role::get_string (nano::thread_role::name role)
|
||||||
case nano::thread_role::name::network_reachout:
|
case nano::thread_role::name::network_reachout:
|
||||||
thread_role_name_string = "Net reachout";
|
thread_role_name_string = "Net reachout";
|
||||||
break;
|
break;
|
||||||
|
case nano::thread_role::name::signal_manager:
|
||||||
|
thread_role_name_string = "Signal manager";
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
debug_assert (false && "nano::thread_role::get_string unhandled thread role");
|
debug_assert (false && "nano::thread_role::get_string unhandled thread role");
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -48,6 +48,7 @@ enum class name
|
||||||
network_cleanup,
|
network_cleanup,
|
||||||
network_keepalive,
|
network_keepalive,
|
||||||
network_reachout,
|
network_reachout,
|
||||||
|
signal_manager,
|
||||||
};
|
};
|
||||||
|
|
||||||
std::string_view to_string (name);
|
std::string_view to_string (name);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue