From: Carl Hetherington Date: Fri, 16 Feb 2018 20:24:37 +0000 (+0000) Subject: Name threads on Linux. X-Git-Tag: v2.13.0~68 X-Git-Url: https://main.carlh.net/gitweb/?p=dcpomatic.git;a=commitdiff_plain;h=8e4a2e5ea578ac4f0f41edb6145d5c0040e33ec2 Name threads on Linux. --- diff --git a/src/lib/butler.cc b/src/lib/butler.cc index 623a17c2f..81ddb1d44 100644 --- a/src/lib/butler.cc +++ b/src/lib/butler.cc @@ -61,6 +61,9 @@ Butler::Butler (shared_ptr player, shared_ptr log, AudioMapping aud _player_video_connection = _player->Video.connect (bind (&Butler::video, this, _1, _2)); _player_audio_connection = _player->Audio.connect (bind (&Butler::audio, this, _1)); _thread = new boost::thread (bind (&Butler::thread, this)); +#ifdef DCPOMATIC_LINUX + pthread_setname_np (_thread->native_handle(), "butler"); +#endif /* Create some threads to do work on the PlayerVideos we are creating; at present this is used to multi-thread JPEG2000 decoding. diff --git a/src/lib/encode_server.cc b/src/lib/encode_server.cc index 332c7ab46..26ef45d60 100644 --- a/src/lib/encode_server.cc +++ b/src/lib/encode_server.cc @@ -229,10 +229,17 @@ EncodeServer::run () } for (int i = 0; i < _num_threads; ++i) { - _worker_threads.push_back (new thread (bind (&EncodeServer::worker_thread, this))); + thread* t = new thread (bind (&EncodeServer::worker_thread, this)); +#ifdef DCPOMATIC_LINUX + pthread_setname_np (t->native_handle(), "encode-server-worker"); +#endif + _worker_threads.push_back (t); } _broadcast.thread = new thread (bind (&EncodeServer::broadcast_thread, this)); +#ifdef DCPOMATIC_LINUX + pthread_setname_np (_broadcast.thread->native_handle(), "encode-server-broadcast"); +#endif Server::run (); } diff --git a/src/lib/encode_server_finder.cc b/src/lib/encode_server_finder.cc index 267fbb62a..e87c55b71 100644 --- a/src/lib/encode_server_finder.cc +++ b/src/lib/encode_server_finder.cc @@ -56,6 +56,10 @@ EncodeServerFinder::start () { _search_thread = new boost::thread (boost::bind (&EncodeServerFinder::search_thread, this)); _listen_thread = new boost::thread (boost::bind (&EncodeServerFinder::listen_thread, this)); +#ifdef DCPOMATIC_LINUX + pthread_setname_np (_search_thread->native_handle(), "encode-server-search"); + pthread_setname_np (_listen_thread->native_handle(), "encode-server-listen"); +#endif } diff --git a/src/lib/j2k_encoder.cc b/src/lib/j2k_encoder.cc index 15977bb3e..3d1df688c 100644 --- a/src/lib/j2k_encoder.cc +++ b/src/lib/j2k_encoder.cc @@ -400,6 +400,9 @@ J2KEncoder::servers_list_changed () if (!Config::instance()->only_servers_encode ()) { for (int i = 0; i < Config::instance()->master_encoding_threads (); ++i) { boost::thread* t = new boost::thread (boost::bind (&J2KEncoder::encoder_thread, this, optional ())); +#ifdef DCPOMATIC_LINUX + pthread_setname_np (t->native_handle(), "encode-worker"); +#endif _threads.push_back (t); #ifdef BOOST_THREAD_PLATFORM_WIN32 if (windows_xp) { diff --git a/src/lib/job.cc b/src/lib/job.cc index 61c5b3767..ccb75fa93 100644 --- a/src/lib/job.cc +++ b/src/lib/job.cc @@ -87,6 +87,9 @@ Job::start () _start_time = time (0); _sub_start_time = time (0); _thread = new boost::thread (boost::bind (&Job::run_wrapper, this)); +#ifdef DCPOMATIC_LINUX + pthread_setname_np (_thread->native_handle(), "job-wrapper"); +#endif } /** A wrapper for the ::run() method to catch exceptions */ diff --git a/src/lib/job_manager.cc b/src/lib/job_manager.cc index d76f86056..e3b6e257b 100644 --- a/src/lib/job_manager.cc +++ b/src/lib/job_manager.cc @@ -53,6 +53,9 @@ void JobManager::start () { _scheduler = new boost::thread (boost::bind (&JobManager::scheduler, this)); +#ifdef DCPOMATIC_LINUX + pthread_setname_np (_scheduler->native_handle(), "job-scheduler"); +#endif } JobManager::~JobManager () diff --git a/src/lib/json_server.cc b/src/lib/json_server.cc index e171a6307..3f43a75eb 100644 --- a/src/lib/json_server.cc +++ b/src/lib/json_server.cc @@ -52,7 +52,10 @@ enum State { JSONServer::JSONServer (int port) { - new thread (boost::bind (&JSONServer::run, this, port)); + thread* t = new thread (boost::bind (&JSONServer::run, this, port)); +#ifdef DCPOMATIC_LINUX + pthread_setname_np (t->native_handle(), "json-server"); +#endif } void diff --git a/src/lib/update_checker.cc b/src/lib/update_checker.cc index 8aeca030b..99060016f 100644 --- a/src/lib/update_checker.cc +++ b/src/lib/update_checker.cc @@ -75,6 +75,9 @@ void UpdateChecker::start () { _thread = new boost::thread (boost::bind (&UpdateChecker::thread, this)); +#ifdef DCPOMATIC_LINUX + pthread_setname_np (_thread->native_handle(), "update-checker"); +#endif } UpdateChecker::~UpdateChecker () diff --git a/src/lib/writer.cc b/src/lib/writer.cc index 10e4514fb..227de6277 100644 --- a/src/lib/writer.cc +++ b/src/lib/writer.cc @@ -106,6 +106,9 @@ void Writer::start () { _thread = new boost::thread (boost::bind (&Writer::thread, this)); +#ifdef DCPOMATIC_LINUX + pthread_setname_np (_thread->native_handle(), "writer"); +#endif } Writer::~Writer () diff --git a/src/tools/dcpomatic.cc b/src/tools/dcpomatic.cc index 05534cc60..2fd8edc3d 100644 --- a/src/tools/dcpomatic.cc +++ b/src/tools/dcpomatic.cc @@ -344,6 +344,10 @@ public: delete[] accel; UpdateChecker::instance()->StateChanged.connect (boost::bind (&DOMFrame::update_checker_state_changed, this)); + +#ifdef DCPOMATIC_LINUX + pthread_setname_np(pthread_self(), "gui"); +#endif } void remove_clicked (wxCommandEvent& ev)