Name threads on Linux.
authorCarl Hetherington <cth@carlh.net>
Fri, 16 Feb 2018 20:24:37 +0000 (20:24 +0000)
committerCarl Hetherington <cth@carlh.net>
Fri, 16 Feb 2018 20:24:37 +0000 (20:24 +0000)
src/lib/butler.cc
src/lib/encode_server.cc
src/lib/encode_server_finder.cc
src/lib/j2k_encoder.cc
src/lib/job.cc
src/lib/job_manager.cc
src/lib/json_server.cc
src/lib/update_checker.cc
src/lib/writer.cc
src/tools/dcpomatic.cc

index 623a17c2fdb13829fb166ac12b2e1838778778cf..81ddb1d44629fcb8b5706e5650978b491275de54 100644 (file)
@@ -61,6 +61,9 @@ Butler::Butler (shared_ptr<Player> player, shared_ptr<Log> 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));
        _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.
 
        /* Create some threads to do work on the PlayerVideos we are creating; at present this is used to
           multi-thread JPEG2000 decoding.
index 332c7ab46d34c858a5ee60e78415b6fe7abd293d..26ef45d60786115e51c166b615c10a116c74e0d7 100644 (file)
@@ -229,10 +229,17 @@ EncodeServer::run ()
        }
 
        for (int i = 0; i < _num_threads; ++i) {
        }
 
        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));
        }
 
        _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 ();
 }
 
        Server::run ();
 }
index 267fbb62ac78235180b42f9df680507513870ada..e87c55b718ff531f4d7d156e4020c4861ec64b79 100644 (file)
@@ -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));
 {
        _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
 }
 
 
 }
 
 
index 15977bb3e6673a47f2cb865593488e66121baf9b..3d1df688c2d718cc2da9a4b2a0c8e00a3a4d6b33 100644 (file)
@@ -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<EncodeServerDescription> ()));
        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<EncodeServerDescription> ()));
+#ifdef DCPOMATIC_LINUX
+                       pthread_setname_np (t->native_handle(), "encode-worker");
+#endif
                        _threads.push_back (t);
 #ifdef BOOST_THREAD_PLATFORM_WIN32
                        if (windows_xp) {
                        _threads.push_back (t);
 #ifdef BOOST_THREAD_PLATFORM_WIN32
                        if (windows_xp) {
index 61c5b376734d202624967f24156dbfe5e7c8f002..ccb75fa9332379ad27488da0e101ba786c150986 100644 (file)
@@ -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));
        _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 */
 }
 
 /** A wrapper for the ::run() method to catch exceptions */
index d76f86056fe9d4dc278768a7d6442d522bb757d3..e3b6e257b4f4a9bb05c7b9e3e2815de9570d5d4a 100644 (file)
@@ -53,6 +53,9 @@ void
 JobManager::start ()
 {
        _scheduler = new boost::thread (boost::bind (&JobManager::scheduler, this));
 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 ()
 }
 
 JobManager::~JobManager ()
index e171a630700252cb1377277e55ff6851c3f891df..3f43a75eb8ee332a53d0a1bac1cb0e2ecc6e1dd0 100644 (file)
@@ -52,7 +52,10 @@ enum State {
 
 JSONServer::JSONServer (int port)
 {
 
 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
 }
 
 void
index 8aeca030bf79f8ba4a7a599ebcce4bf1e11bda88..99060016f4b68bf68365d6166bc7d3ca82c868b2 100644 (file)
@@ -75,6 +75,9 @@ void
 UpdateChecker::start ()
 {
        _thread = new boost::thread (boost::bind (&UpdateChecker::thread, this));
 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 ()
 }
 
 UpdateChecker::~UpdateChecker ()
index 10e4514fbcc134ef333d333d5086511b6b5660a3..227de6277731d4ff31a81649ef8eb24ed114bd1d 100644 (file)
@@ -106,6 +106,9 @@ void
 Writer::start ()
 {
        _thread = new boost::thread (boost::bind (&Writer::thread, this));
 Writer::start ()
 {
        _thread = new boost::thread (boost::bind (&Writer::thread, this));
+#ifdef DCPOMATIC_LINUX
+       pthread_setname_np (_thread->native_handle(), "writer");
+#endif
 }
 
 Writer::~Writer ()
 }
 
 Writer::~Writer ()
index 05534cc608a57697025ed1a18bbd791d1ba3adca..2fd8edc3dae56280b10f4a44f1e7f174bc69936b 100644 (file)
@@ -344,6 +344,10 @@ public:
                delete[] accel;
 
                UpdateChecker::instance()->StateChanged.connect (boost::bind (&DOMFrame::update_checker_state_changed, this));
                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)
        }
 
        void remove_clicked (wxCommandEvent& ev)