From 39d7c9d51bf0a5d545de37ee668c5cbc17b79589 Mon Sep 17 00:00:00 2001 From: Tom Tromey Date: Wed, 3 Jul 2013 16:20:07 -0600 Subject: [PATCH] introduce thread_alive_p macro This introduces the thread_alive_p macro and changes thread-alive-p to use it. This is a minor cleanup. It also changes all-threads to ignore dead threads. --- src/thread.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/src/thread.c b/src/thread.c index 0235944ccdc..361968489c6 100644 --- a/src/thread.c +++ b/src/thread.c @@ -37,6 +37,12 @@ Lisp_Object Qthreadp, Qmutexp, Qcondition_variablep; +/* m_specpdl is set when the thread is created and cleared when the + thread dies. */ +#define thread_alive_p(STATE) ((STATE)->m_specpdl != NULL) + + + static void release_global_lock (void) { @@ -796,9 +802,7 @@ DEFUN ("thread-alive-p", Fthread_alive_p, Sthread_alive_p, 1, 1, 0, CHECK_THREAD (thread); tstate = XTHREAD (thread); - /* m_specpdl is set when the thread is created and cleared when the - thread dies. */ - return tstate->m_specpdl == NULL ? Qnil : Qt; + return thread_alive_p (tstate) ? Qt : Qnil; } DEFUN ("thread-blocker", Fthread_blocker, Sthread_blocker, 1, 1, 0, @@ -865,10 +869,13 @@ DEFUN ("all-threads", Fall_threads, Sall_threads, 0, 0, 0, for (iter = all_threads; iter; iter = iter->next_thread) { - Lisp_Object thread; + if (thread_alive_p (iter)) + { + Lisp_Object thread; - XSETTHREAD (thread, iter); - result = Fcons (thread, result); + XSETTHREAD (thread, iter); + result = Fcons (thread, result); + } } return result; -- 2.39.5