Rename scrcpy threads

Prefix the name of threads by "scrcpy-". This improves readability in
the output of `top -H` for example.

Limit the thread names to 16 bytes, because it is limited on some
platforms.
This commit is contained in:
Romain Vimont
2021-12-09 21:32:11 +01:00
parent 09c55b0f93
commit 3ada5c51bc
12 changed files with 19 additions and 13 deletions

View File

@@ -64,7 +64,7 @@ sc_process_observer_init(struct sc_process_observer *observer, sc_pid pid,
observer->listener_userdata = listener_userdata;
observer->terminated = false;
ok = sc_thread_create(&observer->thread, run_observer, "process_observer",
ok = sc_thread_create(&observer->thread, run_observer, "scrcpy-proc",
observer);
if (!ok) {
sc_cond_destroy(&observer->cond_terminated);

View File

@@ -8,6 +8,10 @@
bool
sc_thread_create(sc_thread *thread, sc_thread_fn fn, const char *name,
void *userdata) {
// The thread name length is limited on some systems. Never use a name
// longer than 16 bytes (including the final '\0')
assert(strlen(name) <= 15);
SDL_Thread *sdl_thread = SDL_CreateThread(fn, name, userdata);
if (!sdl_thread) {
LOG_OOM();