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.
This commit is contained in:
Tom Tromey
2013-07-03 16:20:07 -06:00
parent c60685a8c4
commit 39d7c9d51b

View File

@@ -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;