Add thread names

This commit is contained in:
Robbert van der Helm
2021-06-06 23:45:47 +02:00
parent fe7f6eff96
commit a7496fae77
11 changed files with 41 additions and 3 deletions
+5 -1
View File
@@ -775,7 +775,11 @@ class AdHocSocketHandler {
std::move(secondary_socket));
});
Thread secondary_requests_handler([&]() { secondary_context.run(); });
Thread secondary_requests_handler([&]() {
pthread_setname_np(pthread_self(), "adhoc-acceptor");
secondary_context.run();
});
// Now we'll handle reads on the primary socket in a loop until the
// socket shuts down
+3
View File
@@ -111,6 +111,7 @@ class PluginBridge {
has_realtime_priority_promise.set_value(
set_realtime_priority(true));
set_realtime_priority(false);
pthread_setname_np(pthread_self(), "wine-stdio");
io_context.run();
}) {}
@@ -302,6 +303,8 @@ class PluginBridge {
host_watchdog_handler = std::jthread([&](std::stop_token st) {
using namespace std::literals::chrono_literals;
pthread_setname_np(pthread_self(), "watchdog");
while (!st.stop_requested()) {
if (!plugin_host->running()) {
generic_logger.log(
+1
View File
@@ -73,6 +73,7 @@ Vst2PluginBridge::Vst2PluginBridge(audioMasterCallback host_callback)
// lockstep anyway
host_callback_handler = std::jthread([&]() {
set_realtime_priority(true);
pthread_setname_np(pthread_self(), "host-callbacks");
sockets.vst_host_callback.receive_events(
std::pair<Vst2Logger&, bool>(logger, false),
+1
View File
@@ -49,6 +49,7 @@ Vst3PluginBridge::Vst3PluginBridge()
// configuration.
host_callback_handler = std::jthread([&]() {
set_realtime_priority(true);
pthread_setname_np(pthread_self(), "host-callbacks");
sockets.vst_host_callback.receive_messages(
std::pair<Vst3Logger&, bool>(logger, false),
+1
View File
@@ -171,6 +171,7 @@ GroupHost::GroupHost(boost::asio::io_context& io_context,
group_host_connect_handler =
std::jthread([this, connect, group_host_pid]() {
set_realtime_priority(true);
pthread_setname_np(pthread_self(), "group-connect");
using namespace std::literals::chrono_literals;
+9 -1
View File
@@ -103,7 +103,11 @@ GroupBridge::GroupBridge(boost::filesystem::path group_socket_path)
logger.async_log_pipe_lines(stderr_redirect.pipe, stderr_buffer,
"[STDERR] ");
stdio_handler = Win32Thread([&]() { stdio_context.run(); });
stdio_handler = Win32Thread([&]() {
pthread_setname_np(pthread_self(), "group-stdio");
stdio_context.run();
});
}
GroupBridge::~GroupBridge() noexcept {
@@ -238,6 +242,10 @@ void GroupBridge::accept_requests() {
const size_t plugin_id = next_plugin_id.fetch_add(1);
active_plugins[plugin_id] = std::pair(
Win32Thread([this, plugin_id, plugin_ptr = bridge.get()]() {
const std::string thread_name =
"worker-" + std::to_string(plugin_id);
pthread_setname_np(pthread_self(), thread_name.c_str());
handle_plugin_run(plugin_id, plugin_ptr);
}),
std::move(bridge));
+2
View File
@@ -221,6 +221,7 @@ Vst2Bridge::Vst2Bridge(MainContext& main_context,
parameters_handler = Win32Thread([&]() {
set_realtime_priority(true);
pthread_setname_np(pthread_self(), "parameters");
sockets.host_vst_parameters.receive_multi<Parameter>(
[&](Parameter& request, SerializationBufferBase& buffer) {
@@ -246,6 +247,7 @@ Vst2Bridge::Vst2Bridge(MainContext& main_context,
process_replacing_handler = Win32Thread([&]() {
set_realtime_priority(true);
pthread_setname_np(pthread_self(), "audio");
// Most plugins will already enable FTZ, but there are a handful of
// plugins that don't that suffer from extreme DSP load increases when
+7
View File
@@ -1183,6 +1183,13 @@ size_t Vst3Bridge::register_object_instance(
.audio_processor_handler = Win32Thread([&, instance_id]() {
set_realtime_priority(true);
// XXX: Like with VST2 worker threads, when using plugin groups the
// thread names from different plugins will clash. Not a huge
// deal probably, since duplicate thread names are still more
// useful than no thread names.
const std::string thread_name = "audio-" + std::to_string(instance_id);
pthread_setname_np(pthread_self(), thread_name.c_str());
sockets.add_audio_processor_and_listen(
instance_id, socket_listening_latch,
overload{
+2
View File
@@ -117,6 +117,8 @@ __cdecl
// potentially unsafe events that should always be run from the UI thread
// will be posted to `main_context`.
Win32Thread worker_thread([&]() {
pthread_setname_np(pthread_self(), "worker");
bridge->run();
// // When the sockets get closed, this application should
+5 -1
View File
@@ -86,7 +86,11 @@ MainContext::MainContext()
// we'll run the timer on a 30 second interval.
async_handle_watchdog_timer(5s);
watchdog_handler = Win32Thread([&]() { watchdog_context.run(); });
watchdog_handler = Win32Thread([&]() {
pthread_setname_np(pthread_self(), "watchdog");
watchdog_context.run();
});
}
void MainContext::run() {