Skip to content

Commit c27759e

Browse files
tstennercboulay
authored andcommitted
Name service threads properly
1 parent 800c23d commit c27759e

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/stream_outlet_impl.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
#include "tcp_server.h"
77
#include "udp_server.h"
88
#include <algorithm>
9+
#include <asio/post.hpp>
910
#include <chrono>
1011
#include <memory>
1112

@@ -57,10 +58,8 @@ stream_outlet_impl::stream_outlet_impl(const stream_info_impl &info, int32_t chu
5758
for (auto &responder : responders_) responder->begin_serving();
5859

5960
// and start the IO threads to handle them
60-
const std::string name{"IO_" + this->info().name().substr(0, 11)};
6161
for (const auto &io : {io_ctx_data_, io_ctx_service_})
62-
io_threads_.emplace_back(std::make_shared<std::thread>([io, name]() {
63-
loguru::set_thread_name(name.c_str());
62+
io_threads_.emplace_back(std::make_shared<std::thread>([io]() {
6463
while (true) {
6564
try {
6665
io->run();
@@ -70,6 +69,10 @@ stream_outlet_impl::stream_outlet_impl(const stream_info_impl &info, int32_t chu
7069
}
7170
}
7271
}));
72+
73+
const std::string name{this->info().name().substr(0, 11)};
74+
asio::post(*io_ctx_data_, [name]() { loguru::set_thread_name(("IO_" + name).c_str()); });
75+
asio::post(*io_ctx_service_, [name]() { loguru::set_thread_name(("SVC_" + name).c_str()); });
7376
}
7477

7578
void stream_outlet_impl::instantiate_stack(udp udp_protocol) {

0 commit comments

Comments
 (0)