Skip to content

Commit

Permalink
set thread names for debugger
Browse files Browse the repository at this point in the history
  • Loading branch information
pablohoch committed Nov 4, 2024
1 parent 42cfb4b commit 1eb8b3e
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .pkg
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
[utl]
[email protected]:motis-project/utl.git
branch=master
commit=f76f70812be09d88b260e398ddd43fc7345f9fb9
commit=9c44a5abcb62c0463df87355e0cb29d90906f0d0
[adr]
[email protected]:triptix-tech/adr.git
branch=master
Expand Down
4 changes: 2 additions & 2 deletions .pkg.lock
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
521520066768043934
14846770624705372750
cista 5b6808fd7d7a7c1c7e4cb152b563dbf71e3efba4
zlib-ng 68ab3e2d80253ec5dc3c83691d9ff70477b32cd3
boost 73549ebca677fe6214202a1ab580362b4f80e653
googletest 7b64fca6ea0833628d6f86255a81424365f7cc0c
libressl 24acd9e710fbe842e863572da9d738715fbc74b8
fmt dc10f83be70ac2873d5f8d1ce317596f1fd318a2
utl f76f70812be09d88b260e398ddd43fc7345f9fb9
utl 9c44a5abcb62c0463df87355e0cb29d90906f0d0
net 7b089e022471bb5adf716d0c7b0cdb57a23c7adc
PEGTL 1c1aa6e650e4d26f10fa398f148ec0cdc5f0808d
res b759b93316afeb529b6cb5b2548b24c41e382fb0
Expand Down
9 changes: 8 additions & 1 deletion src/server.cc
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
#include "boost/asio/io_context.hpp"

#include "fmt/format.h"

#include "net/run.h"
#include "net/stop_handler.h"
#include "net/web_server/query_router.h"
#include "net/web_server/web_server.h"

#include "utl/enumerate.h"
#include "utl/init_from.h"
#include "utl/set_thread_name.h"

#include "motis/config.h"
#include "motis/endpoints/adr/geocode.h"
Expand Down Expand Up @@ -97,6 +101,7 @@ int server(data d, config const& c) {
if (c.requires_rt_timetable_updates()) {
rt_update_ioc = std::make_unique<asio::io_context>();
rt_update_thread = std::make_unique<std::thread>([&]() {
utl::set_current_thread_name("rt update");
run_rt_update(*rt_update_ioc, c, *d.tt_, *d.tags_, d.rt_);
rt_update_ioc->run();
});
Expand All @@ -107,6 +112,7 @@ int server(data d, config const& c) {
if (d.w_ && d.l_ && c.has_gbfs_feeds()) {
gbfs_update_ioc = std::make_unique<asio::io_context>();
gbfs_update_thread = std::make_unique<std::thread>([&]() {
utl::set_current_thread_name("gbfs update");
gbfs::run_gbfs_update(*gbfs_update_ioc, c, *d.w_, *d.l_, d.gbfs_);
gbfs_update_ioc->run();
});
Expand All @@ -115,8 +121,9 @@ int server(data d, config const& c) {
auto const work_guard = asio::make_work_guard(workers);
auto threads = std::vector<std::thread>(
static_cast<unsigned>(std::max(1U, server_config.n_threads_)));
for (auto& t : threads) {
for (auto [i, t] : utl::enumerate(threads)) {
t = std::thread(net::run(workers));
utl::set_thread_name(t, fmt::format("worker {}", i));
}

auto const stop = net::stop_handler(ioc, [&]() {
Expand Down

0 comments on commit 1eb8b3e

Please sign in to comment.