13
0

Let PBD::Thread set thread-name

This commit is contained in:
Robin Gareus 2024-09-28 00:14:45 +02:00
parent 538a8cbccc
commit 88a24ae8e5
Signed by: rgareus
GPG Key ID: A090BCE02CF57F04
23 changed files with 13 additions and 55 deletions

View File

@ -678,7 +678,6 @@ void
AudioEngine::do_reset_backend()
{
SessionEvent::create_per_thread_pool (X_("Backend reset processing thread"), 1024);
pthread_set_name ("EngineWatchdog");
Glib::Threads::Mutex::Lock guard (_reset_request_lock);
@ -739,7 +738,6 @@ void
AudioEngine::do_devicelist_update()
{
SessionEvent::create_per_thread_pool (X_("Device list update processing thread"), 512);
pthread_set_name ("DeviceList");
Glib::Threads::Mutex::Lock guard (_devicelist_update_lock);
@ -769,13 +767,13 @@ AudioEngine::start_hw_event_processing()
if (_hw_reset_event_thread == 0) {
_hw_reset_request_count.store (0);
_stop_hw_reset_processing.store (0);
_hw_reset_event_thread = PBD::Thread::create (boost::bind (&AudioEngine::do_reset_backend, this));
_hw_reset_event_thread = PBD::Thread::create (boost::bind (&AudioEngine::do_reset_backend, this), "EngineWatchdog");
}
if (_hw_devicelist_update_thread == 0) {
_hw_devicelist_update_count.store (0);
_stop_hw_devicelist_processing.store (0);
_hw_devicelist_update_thread = PBD::Thread::create (boost::bind (&AudioEngine::do_devicelist_update, this));
_hw_devicelist_update_thread = PBD::Thread::create (boost::bind (&AudioEngine::do_devicelist_update, this), "DeviceList");
}
}

View File

@ -202,7 +202,6 @@ void
AutomationWatch::thread ()
{
pbd_set_thread_priority (pthread_self(), PBD_SCHED_FIFO, AudioEngine::instance()->client_real_time_priority() - 2); // XXX
pthread_set_name ("AutomationWatch");
while (_run_thread) {
Glib::usleep ((gulong) floor (Config->get_automation_interval_msecs() * 1000)); // TODO use pthread_cond_timedwait on _run_thread
timer ();
@ -224,7 +223,7 @@ AutomationWatch::set_session (Session* s)
if (_session) {
_run_thread = true;
_thread = PBD::Thread::create (boost::bind (&AutomationWatch::thread, this));
_thread = PBD::Thread::create (boost::bind (&AutomationWatch::thread, this), "AutomationWatch");
_session->TransportStateChange.connect_same_thread (transport_connection, boost::bind (&AutomationWatch::transport_state_change, this));
}

View File

@ -141,7 +141,7 @@ Butler::start_thread ()
should_run = false;
if (pthread_create_and_store ("disk butler", &thread, _thread_work, this)) {
if (pthread_create_and_store ("butler", &thread, _thread_work, this)) {
error << _("Session: could not create butler thread") << endmsg;
return -1;
}
@ -171,7 +171,6 @@ void*
Butler::_thread_work (void* arg)
{
SessionEvent::create_per_thread_pool ("butler events", 4096);
pthread_set_name (X_("butler"));
/* get thread buffers for RegionFx */
ARDOUR::ProcessThread* pt = new ProcessThread ();
pt->get_buffers ();

View File

@ -275,7 +275,6 @@ MidiPatchManager::load_midnams ()
*/
PBD::notify_event_loops_about_thread_creation (pthread_self(), "midi-patch-manager", 8);
pthread_set_name ("MIDNAMLoader");
{
PBD::Unwinder<bool> npc (no_patch_changed_messages, true);
@ -291,7 +290,7 @@ MidiPatchManager::load_midnams ()
void
MidiPatchManager::load_midnams_in_thread ()
{
_midnam_load_thread = PBD::Thread::create (boost::bind (&MidiPatchManager::load_midnams, this));
_midnam_load_thread = PBD::Thread::create (boost::bind (&MidiPatchManager::load_midnams, this), "MIDNAMLoader");
}
void

View File

@ -65,8 +65,6 @@ static void
peak_thread_work ()
{
SessionEvent::create_per_thread_pool (X_("PeakFile Builder "), 64);
pthread_set_name ("PeakFileBuilder");
while (true) {
SourceFactory::peak_building_lock.lock ();
@ -119,7 +117,7 @@ SourceFactory::init ()
}
peak_thread_run = true;
for (int n = 0; n < 2; ++n) {
peak_thread_pool.push_back (PBD::Thread::create (&peak_thread_work));
peak_thread_pool.push_back (PBD::Thread::create (&peak_thread_work, string_compose ("PeakFileBuilder-%1", n)));
}
}

View File

@ -4879,7 +4879,7 @@ TriggerBoxThread::TriggerBoxThread ()
: requests (1024)
, _xthread (true)
{
if (pthread_create_and_store ("triggerbox thread", &thread, _thread_work, this)) {
if (pthread_create_and_store ("TriggerBox Worker", &thread, _thread_work, this)) {
error << _("Session: could not create triggerbox thread") << endmsg;
throw failed_constructor ();
}
@ -4897,15 +4897,12 @@ void *
TriggerBoxThread::_thread_work (void* arg)
{
SessionEvent::create_per_thread_pool ("tbthread events", 4096);
pthread_set_name (X_("tbthread"));
return ((TriggerBoxThread *) arg)->thread_work ();
}
void *
TriggerBoxThread::thread_work ()
{
pthread_set_name (X_("Trigger Worker"));
while (true) {
char msg;

View File

@ -41,7 +41,7 @@ Worker::Worker(Workee* workee, uint32_t ring_size, bool threaded)
, _synchronous(!threaded)
{
if (threaded) {
_thread = PBD::Thread::create (boost::bind (&Worker::run, this));
_thread = PBD::Thread::create (boost::bind (&Worker::run, this), "LV2Worker");
}
}
@ -137,8 +137,6 @@ Worker::emit_responses()
void
Worker::run()
{
pthread_set_name ("LV2Worker");
void* buf = NULL;
size_t buf_size = 0;
while (true) {

View File

@ -136,7 +136,6 @@ class TmpFileRt
static void * _disk_thread (void *arg)
{
TmpFileRt *d = static_cast<TmpFileRt *>(arg);
pthread_set_name ("ExportDiskIO");
d->disk_thread ();
return 0;
}

View File

@ -94,7 +94,6 @@ BaseUI::set_thread_priority () const
void
BaseUI::main_thread ()
{
pthread_set_name (string_compose ("UI:%1", event_loop_name ()).c_str ());
DEBUG_TRACE (DEBUG::EventLoop, string_compose ("%1: event loop running in thread %2\n", event_loop_name(), pthread_name()));
set_event_loop_for_thread (this);
thread_init ();
@ -122,7 +121,7 @@ BaseUI::run ()
attach_request_source ();
Glib::Threads::Mutex::Lock lm (_run_lock);
_run_loop_thread = PBD::Thread::create (boost::bind (&BaseUI::main_thread, this));
_run_loop_thread = PBD::Thread::create (boost::bind (&BaseUI::main_thread, this), string_compose ("UI:%1", event_loop_name ()));
_running.wait (_run_lock);
}

View File

@ -98,7 +98,7 @@ Downloader::start ()
_cancel = false;
_status = 0; /* unknown at this point */
return 0 != (thread = PBD::Thread::create (boost::bind (&Downloader::download, this)));
return 0 != (thread = PBD::Thread::create (boost::bind (&Downloader::download, this), "Downloader"));
}
void

View File

@ -45,7 +45,7 @@ Inflater::~Inflater ()
int
Inflater::start ()
{
return 0 != (thread = PBD::Thread::create (boost::bind (&Inflater::threaded_inflate, this)));
return 0 != (thread = PBD::Thread::create (boost::bind (&Inflater::threaded_inflate, this), "Inflater"));
}
void

View File

@ -258,8 +258,6 @@ CC121::stop ()
void
CC121::thread_init ()
{
pthread_set_name (event_loop_name().c_str());
PBD::notify_event_loops_about_thread_creation (pthread_self(), event_loop_name(), 2048);
ARDOUR::SessionEvent::create_per_thread_pool (event_loop_name(), 128);

View File

@ -238,8 +238,6 @@ void
ContourDesignControlProtocol::thread_init ()
{
DEBUG_TRACE (DEBUG::ContourDesignControl, "thread_init()\n");
pthread_set_name (X_("contourdesign"));
PBD::notify_event_loops_about_thread_creation (pthread_self (), X_("contourdesign"), 2048);
ARDOUR::SessionEvent::create_per_thread_pool (X_("contourdesign"), 128);

View File

@ -283,8 +283,6 @@ FaderPort8::stop ()
void
FaderPort8::thread_init ()
{
pthread_set_name (event_loop_name().c_str());
PBD::notify_event_loops_about_thread_creation (pthread_self(), event_loop_name(), 2048);
ARDOUR::SessionEvent::create_per_thread_pool (event_loop_name(), 128);

View File

@ -308,8 +308,6 @@ GenericMidiControlProtocol::stop ()
void
GenericMidiControlProtocol::thread_init ()
{
pthread_set_name (event_loop_name().c_str());
PBD::notify_event_loops_about_thread_creation (pthread_self(), event_loop_name(), 2048);
ARDOUR::SessionEvent::create_per_thread_pool (event_loop_name(), 128);

View File

@ -665,8 +665,6 @@ void LaunchControlXL::handle_midi_note_off_message(MIDI::Parser & parser, MIDI::
void
LaunchControlXL::thread_init ()
{
pthread_set_name (event_loop_name().c_str());
PBD::notify_event_loops_about_thread_creation (pthread_self(), event_loop_name(), 2048);
ARDOUR::SessionEvent::create_per_thread_pool (event_loop_name(), 128);

View File

@ -194,8 +194,6 @@ MackieControlProtocol::~MackieControlProtocol()
void
MackieControlProtocol::thread_init ()
{
pthread_set_name (event_loop_name().c_str());
PBD::notify_event_loops_about_thread_creation (pthread_self(), event_loop_name(), 2048);
ARDOUR::SessionEvent::create_per_thread_pool (event_loop_name(), 128);

View File

@ -307,16 +307,9 @@ Maschine2::stop ()
void
Maschine2::thread_init ()
{
pthread_set_name (event_loop_name().c_str());
ARDOUR::SessionEvent::create_per_thread_pool (event_loop_name(), 1024);
PBD::notify_event_loops_about_thread_creation (pthread_self(), event_loop_name(), 1024);
struct sched_param rtparam;
memset (&rtparam, 0, sizeof (rtparam));
rtparam.sched_priority = 9; /* XXX should be relative to audio (JACK) thread */
if (pthread_setschedparam (pthread_self(), SCHED_FIFO, &rtparam) != 0) {
// do we care? not particularly.
}
set_thread_priority ();
}
void

View File

@ -284,8 +284,6 @@ OSC::start ()
void
OSC::thread_init ()
{
pthread_set_name (event_loop_name().c_str());
if (_osc_unix_server) {
Glib::RefPtr<IOSource> src = IOSource::create (lo_server_get_socket_fd (_osc_unix_server), IO_IN|IO_HUP|IO_ERR);
src->connect (sigc::bind (sigc::mem_fun (*this, &OSC::osc_input_handler), _osc_unix_server));

View File

@ -174,8 +174,6 @@ US2400Protocol::~US2400Protocol()
void
US2400Protocol::thread_init ()
{
pthread_set_name (event_loop_name().c_str());
PBD::notify_event_loops_about_thread_creation (pthread_self(), event_loop_name(), 2048);
ARDOUR::SessionEvent::create_per_thread_pool (event_loop_name(), 128);

View File

@ -76,7 +76,6 @@ ArdourWebsockets::set_active (bool yn)
void
ArdourWebsockets::thread_init ()
{
pthread_set_name (event_loop_name ().c_str ());
PBD::notify_event_loops_about_thread_creation (pthread_self (), event_loop_name (), 2048);
SessionEvent::create_per_thread_pool (event_loop_name (), 128);
}

View File

@ -154,8 +154,6 @@ WiimoteControlProtocol::thread_init ()
{
DEBUG_TRACE (DEBUG::WiimoteControl, "WiimoteControlProtocol::thread_init init\n");
pthread_set_name (X_("wiimote"));
// allow to make requests to the GUI and RT thread(s)
PBD::notify_event_loops_about_thread_creation (pthread_self (), X_("wiimote"), 2048);
BasicUI::register_thread ("wiimote");

View File

@ -405,7 +405,7 @@ WaveViewDrawingThread::start ()
{
assert (!_thread);
_thread = PBD::Thread::create (&WaveViewThreads::thread_proc);
_thread = PBD::Thread::create (&WaveViewThreads::thread_proc, "WaveViewDrawing");
}
void
@ -477,8 +477,6 @@ WaveViewThreads::thread_proc ()
void
WaveViewThreads::_thread_proc ()
{
pthread_set_name ("WaveViewDrawing");
while (true) {
_queue_mutex.lock ();