Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Signal manager thread role #4565

Merged
merged 1 commit into from
Apr 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions nano/lib/signal_manager.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include <nano/lib/signal_manager.hpp>
#include <nano/lib/thread_roles.hpp>
#include <nano/lib/utility.hpp>

#include <boost/asio.hpp>
Expand All @@ -10,7 +11,8 @@
nano::signal_manager::signal_manager () :
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 ();
});
}
Expand All @@ -21,7 +23,7 @@ nano::signal_manager::~signal_manager ()
/// io_context::run() function will exit once all other work has completed.
work.reset ();
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) :
Expand Down
4 changes: 2 additions & 2 deletions nano/lib/signal_manager.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@

#include <boost/asio.hpp>
#include <boost/system/error_code.hpp>
#include <boost/thread.hpp>

#include <iostream>
#include <memory>
#include <string>
#include <thread>
#include <vector>

namespace nano
Expand Down Expand Up @@ -73,7 +73,7 @@ class signal_manager final
std::vector<signal_descriptor> descriptor_list;

/** thread to service the signal manager io context */
boost::thread smthread;
std::thread thread;
};

}
3 changes: 3 additions & 0 deletions nano/lib/thread_roles.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,9 @@ std::string nano::thread_role::get_string (nano::thread_role::name role)
case nano::thread_role::name::network_reachout:
thread_role_name_string = "Net reachout";
break;
case nano::thread_role::name::signal_manager:
thread_role_name_string = "Signal manager";
break;
default:
debug_assert (false && "nano::thread_role::get_string unhandled thread role");
}
Expand Down
1 change: 1 addition & 0 deletions nano/lib/thread_roles.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ enum class name
network_cleanup,
network_keepalive,
network_reachout,
signal_manager,
};

std::string_view to_string (name);
Expand Down
Loading