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 623a17c..81ddb1d 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));
+#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.
index 332c7ab..26ef45d 100644 (file)
@@ -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 ();
 }
index 267fbb6..e87c55b 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));
+#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 15977bb..3d1df68 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> ()));
+#ifdef DCPOMATIC_LINUX
+                       pthread_setname_np (t->native_handle(), "encode-worker");
+#endif
                        _threads.push_back (t);
 #ifdef BOOST_THREAD_PLATFORM_WIN32
                        if (windows_xp) {
index 61c5b37..ccb75fa 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));
+#ifdef DCPOMATIC_LINUX
+       pthread_setname_np (_thread->native_handle(), "job-wrapper");
+#endif
 }
 
 /** A wrapper for the ::run() method to catch exceptions */
index d76f860..e3b6e25 100644 (file)
@@ -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 ()
index e171a63..3f43a75 100644 (file)
@@ -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
index 8aeca03..9906001 100644 (file)
@@ -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 ()
index 10e4514..227de62 100644 (file)
@@ -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 ()
index 05534cc..2fd8edc 100644 (file)
@@ -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)