From 55ed50ba901e70adda09f1cf8c0de7cf80cabeb3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kacper=20Michaj=C5=82ow?= Date: Sun, 22 Oct 2023 02:34:42 +0200 Subject: mp_thread: prefer tracking threads with id This change essentially removes mp_thread_self() and instead add mp_thread_id to track threads and have ability to query current thread id during runtime. This will be useful for upcoming win32 implementation, where accessing thread handle is different than on pthreads. Greatly reduces complexity. Otherweis locked map of tid <-> handle is required which is completely unnecessary for all mpv use-cases. Note that this is the mp_thread_id, not to confuse with system tid. For example on threads-posix implementation it is simply pthread_t. --- input/ipc-unix.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'input/ipc-unix.c') diff --git a/input/ipc-unix.c b/input/ipc-unix.c index 595cf7f029..a416b54e1e 100644 --- a/input/ipc-unix.c +++ b/input/ipc-unix.c @@ -92,8 +92,6 @@ static int ipc_write_str(struct client_arg *client, const char *buf) static MP_THREAD_VOID client_thread(void *p) { - pthread_detach(mp_thread_self()); - // We don't use MSG_NOSIGNAL because the moldy fruit OS doesn't support it. struct sigaction sa = { .sa_handler = SIG_IGN, .sa_flags = SA_RESTART }; sigfillset(&sa.sa_mask); @@ -234,6 +232,7 @@ static bool ipc_start_client(struct mp_ipc_ctx *ctx, struct client_arg *client, mp_thread client_thr; if (mp_thread_create(&client_thr, client_thread, client)) goto err; + mp_thread_detach(client_thr); return true; -- cgit v1.2.3