aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorTom Tromey2013-07-03 16:20:07 -0600
committerTom Tromey2013-07-03 16:20:07 -0600
commit39d7c9d51bf0a5d545de37ee668c5cbc17b79589 (patch)
tree4c3efca7443bf86c221ba9635c83dc22dfd9c59c /src
parentc60685a8c4f1a7cc15c8fd2cd53fe9bb27245baf (diff)
downloademacs-39d7c9d51bf0a5d545de37ee668c5cbc17b79589.tar.gz
emacs-39d7c9d51bf0a5d545de37ee668c5cbc17b79589.zip
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.
Diffstat (limited to 'src')
-rw-r--r--src/thread.c19
1 files 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;
37 37
38 38
39 39
40/* m_specpdl is set when the thread is created and cleared when the
41 thread dies. */
42#define thread_alive_p(STATE) ((STATE)->m_specpdl != NULL)
43
44
45
40static void 46static void
41release_global_lock (void) 47release_global_lock (void)
42{ 48{
@@ -796,9 +802,7 @@ DEFUN ("thread-alive-p", Fthread_alive_p, Sthread_alive_p, 1, 1, 0,
796 CHECK_THREAD (thread); 802 CHECK_THREAD (thread);
797 tstate = XTHREAD (thread); 803 tstate = XTHREAD (thread);
798 804
799 /* m_specpdl is set when the thread is created and cleared when the 805 return thread_alive_p (tstate) ? Qt : Qnil;
800 thread dies. */
801 return tstate->m_specpdl == NULL ? Qnil : Qt;
802} 806}
803 807
804DEFUN ("thread-blocker", Fthread_blocker, Sthread_blocker, 1, 1, 0, 808DEFUN ("thread-blocker", Fthread_blocker, Sthread_blocker, 1, 1, 0,
@@ -865,10 +869,13 @@ DEFUN ("all-threads", Fall_threads, Sall_threads, 0, 0, 0,
865 869
866 for (iter = all_threads; iter; iter = iter->next_thread) 870 for (iter = all_threads; iter; iter = iter->next_thread)
867 { 871 {
868 Lisp_Object thread; 872 if (thread_alive_p (iter))
873 {
874 Lisp_Object thread;
869 875
870 XSETTHREAD (thread, iter); 876 XSETTHREAD (thread, iter);
871 result = Fcons (thread, result); 877 result = Fcons (thread, result);
878 }
872 } 879 }
873 880
874 return result; 881 return result;