aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Albinus2018-08-31 10:47:03 +0200
committerMichael Albinus2018-08-31 10:47:03 +0200
commitac7936cb8f4d4d6706535bfcea0d97741c2ca15f (patch)
tree3399f9b5994fda2d8d6254985032803bf5958700
parent3d09d533d15eae2974f3858df43746cf6e8f897b (diff)
downloademacs-ac7936cb8f4d4d6706535bfcea0d97741c2ca15f.tar.gz
emacs-ac7936cb8f4d4d6706535bfcea0d97741c2ca15f.zip
Rename thread-alive-p to thread-live-p
* doc/lispref/threads.texi (Basic Thread Functions): Use thread-live-p. * etc/NEWS: 'thread-alive-p' has been renamed to 'thread-live-p'. * src/thread.c (thread_live_p): Rename from thread_alive_p. Adapt all callees. (Fthread_live_p): Rename from Fthread_alive_p. (syms_of_threads): Make thread-alive-p an alias of thread-live-p. * test/src/thread-tests.el (all): Replace `thread-alive-p' by `thread-live-p'. (threads-live): Rename from `threads-alive'.
-rw-r--r--doc/lispref/threads.texi2
-rw-r--r--etc/NEWS5
-rw-r--r--src/thread.c17
-rw-r--r--test/src/thread-tests.el16
4 files changed, 24 insertions, 16 deletions
diff --git a/doc/lispref/threads.texi b/doc/lispref/threads.texi
index f05af496188..ddeb2e923fc 100644
--- a/doc/lispref/threads.texi
+++ b/doc/lispref/threads.texi
@@ -97,7 +97,7 @@ Yield execution to the next runnable thread.
97Return the name of @var{thread}, as specified to @code{make-thread}. 97Return the name of @var{thread}, as specified to @code{make-thread}.
98@end defun 98@end defun
99 99
100@defun thread-alive-p thread 100@defun thread-live-p thread
101Return @code{t} if @var{thread} is alive, or @code{nil} if it is not. 101Return @code{t} if @var{thread} is alive, or @code{nil} if it is not.
102A thread is alive as long as its function is still executing. 102A thread is alive as long as its function is still executing.
103@end defun 103@end defun
diff --git a/etc/NEWS b/etc/NEWS
index ffea247dd5a..f575d4dd005 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -112,6 +112,11 @@ option 'vc-hg-symbolic-revision-styles' to the value '("{rev}")'.
112Existing files "~/.emacs.d/shadows" and "~/.emacs.d/shadow_todo" must 112Existing files "~/.emacs.d/shadows" and "~/.emacs.d/shadow_todo" must
113be removed prior using the changed 'shadow-*' commands. 113be removed prior using the changed 'shadow-*' commands.
114 114
115+++
116** 'thread-alive-p' has been renamed to 'thread-live-p'.
117The old name is an alias of the new name. Future Emacs version will
118obsolete it.
119
115 120
116* Lisp Changes in Emacs 26.2 121* Lisp Changes in Emacs 26.2
117 122
diff --git a/src/thread.c b/src/thread.c
index 04c2808e5c4..9b450ee0a45 100644
--- a/src/thread.c
+++ b/src/thread.c
@@ -41,7 +41,7 @@ extern volatile int interrupt_input_blocked;
41 41
42/* m_specpdl is set when the thread is created and cleared when the 42/* m_specpdl is set when the thread is created and cleared when the
43 thread dies. */ 43 thread dies. */
44#define thread_alive_p(STATE) ((STATE)->m_specpdl != NULL) 44#define thread_live_p(STATE) ((STATE)->m_specpdl != NULL)
45 45
46 46
47 47
@@ -884,7 +884,7 @@ or `thread-join' in the target thread. */)
884 return Qnil; 884 return Qnil;
885} 885}
886 886
887DEFUN ("thread-alive-p", Fthread_alive_p, Sthread_alive_p, 1, 1, 0, 887DEFUN ("thread-live-p", Fthread_live_p, Sthread_live_p, 1, 1, 0,
888 doc: /* Return t if THREAD is alive, or nil if it has exited. */) 888 doc: /* Return t if THREAD is alive, or nil if it has exited. */)
889 (Lisp_Object thread) 889 (Lisp_Object thread)
890{ 890{
@@ -893,7 +893,7 @@ DEFUN ("thread-alive-p", Fthread_alive_p, Sthread_alive_p, 1, 1, 0,
893 CHECK_THREAD (thread); 893 CHECK_THREAD (thread);
894 tstate = XTHREAD (thread); 894 tstate = XTHREAD (thread);
895 895
896 return thread_alive_p (tstate) ? Qt : Qnil; 896 return thread_live_p (tstate) ? Qt : Qnil;
897} 897}
898 898
899DEFUN ("thread--blocker", Fthread_blocker, Sthread_blocker, 1, 1, 0, 899DEFUN ("thread--blocker", Fthread_blocker, Sthread_blocker, 1, 1, 0,
@@ -923,7 +923,7 @@ thread_join_callback (void *arg)
923 XSETTHREAD (thread, tstate); 923 XSETTHREAD (thread, tstate);
924 self->event_object = thread; 924 self->event_object = thread;
925 self->wait_condvar = &tstate->thread_condvar; 925 self->wait_condvar = &tstate->thread_condvar;
926 while (thread_alive_p (tstate) && NILP (self->error_symbol)) 926 while (thread_live_p (tstate) && NILP (self->error_symbol))
927 sys_cond_wait (self->wait_condvar, &global_lock); 927 sys_cond_wait (self->wait_condvar, &global_lock);
928 928
929 self->wait_condvar = NULL; 929 self->wait_condvar = NULL;
@@ -946,7 +946,7 @@ It is an error for a thread to try to join itself. */)
946 if (tstate == current_thread) 946 if (tstate == current_thread)
947 error ("Cannot join current thread"); 947 error ("Cannot join current thread");
948 948
949 if (thread_alive_p (tstate)) 949 if (thread_live_p (tstate))
950 flush_stack_call_func (thread_join_callback, tstate); 950 flush_stack_call_func (thread_join_callback, tstate);
951 951
952 return Qnil; 952 return Qnil;
@@ -961,7 +961,7 @@ DEFUN ("all-threads", Fall_threads, Sall_threads, 0, 0, 0,
961 961
962 for (iter = all_threads; iter; iter = iter->next_thread) 962 for (iter = all_threads; iter; iter = iter->next_thread)
963 { 963 {
964 if (thread_alive_p (iter)) 964 if (thread_live_p (iter))
965 { 965 {
966 Lisp_Object thread; 966 Lisp_Object thread;
967 967
@@ -1051,7 +1051,7 @@ syms_of_threads (void)
1051 defsubr (&Scurrent_thread); 1051 defsubr (&Scurrent_thread);
1052 defsubr (&Sthread_name); 1052 defsubr (&Sthread_name);
1053 defsubr (&Sthread_signal); 1053 defsubr (&Sthread_signal);
1054 defsubr (&Sthread_alive_p); 1054 defsubr (&Sthread_live_p);
1055 defsubr (&Sthread_join); 1055 defsubr (&Sthread_join);
1056 defsubr (&Sthread_blocker); 1056 defsubr (&Sthread_blocker);
1057 defsubr (&Sall_threads); 1057 defsubr (&Sall_threads);
@@ -1069,6 +1069,9 @@ syms_of_threads (void)
1069 staticpro (&last_thread_error); 1069 staticpro (&last_thread_error);
1070 last_thread_error = Qnil; 1070 last_thread_error = Qnil;
1071 1071
1072 Fdefalias (intern_c_string ("thread-alive-p"),
1073 intern_c_string ("thread-live-p"), Qnil);
1074
1072 Fprovide (intern_c_string ("threads"), Qnil); 1075 Fprovide (intern_c_string ("threads"), Qnil);
1073 } 1076 }
1074 1077
diff --git a/test/src/thread-tests.el b/test/src/thread-tests.el
index a00a9c84bd6..e721e0f9621 100644
--- a/test/src/thread-tests.el
+++ b/test/src/thread-tests.el
@@ -32,7 +32,7 @@
32(declare-function mutex-lock "thread.c" (mutex)) 32(declare-function mutex-lock "thread.c" (mutex))
33(declare-function mutex-unlock "thread.c" (mutex)) 33(declare-function mutex-unlock "thread.c" (mutex))
34(declare-function thread--blocker "thread.c" (thread)) 34(declare-function thread--blocker "thread.c" (thread))
35(declare-function thread-alive-p "thread.c" (thread)) 35(declare-function thread-live-p "thread.c" (thread))
36(declare-function thread-join "thread.c" (thread)) 36(declare-function thread-join "thread.c" (thread))
37(declare-function thread-last-error "thread.c" ()) 37(declare-function thread-last-error "thread.c" ())
38(declare-function thread-name "thread.c" (thread)) 38(declare-function thread-name "thread.c" (thread))
@@ -60,11 +60,11 @@
60 (should 60 (should
61 (string= "hi bob" (thread-name (make-thread #'ignore "hi bob"))))) 61 (string= "hi bob" (thread-name (make-thread #'ignore "hi bob")))))
62 62
63(ert-deftest threads-alive () 63(ert-deftest threads-live ()
64 "Test for thread liveness." 64 "Test for thread liveness."
65 (skip-unless (featurep 'threads)) 65 (skip-unless (featurep 'threads))
66 (should 66 (should
67 (thread-alive-p (make-thread #'ignore)))) 67 (thread-live-p (make-thread #'ignore))))
68 68
69(ert-deftest threads-all-threads () 69(ert-deftest threads-all-threads ()
70 "Simple test for all-threads." 70 "Simple test for all-threads."
@@ -96,7 +96,7 @@
96 (let ((thread (make-thread #'threads-test-thread1))) 96 (let ((thread (make-thread #'threads-test-thread1)))
97 (thread-join thread) 97 (thread-join thread)
98 (and threads-test-global 98 (and threads-test-global
99 (not (thread-alive-p thread))))))) 99 (not (thread-live-p thread)))))))
100 100
101(ert-deftest threads-join-self () 101(ert-deftest threads-join-self ()
102 "Cannot `thread-join' the current thread." 102 "Cannot `thread-join' the current thread."
@@ -271,7 +271,7 @@
271 (let (th1 th2) 271 (let (th1 th2)
272 (setq th1 (make-thread #'threads-call-error "call-error")) 272 (setq th1 (make-thread #'threads-call-error "call-error"))
273 (should (threadp th1)) 273 (should (threadp th1))
274 (while (thread-alive-p th1) 274 (while (thread-live-p th1)
275 (thread-yield)) 275 (thread-yield))
276 (should (equal (thread-last-error) 276 (should (equal (thread-last-error)
277 '(error "Error is called"))) 277 '(error "Error is called")))
@@ -297,7 +297,7 @@
297 (while t (thread-yield)))))) 297 (while t (thread-yield))))))
298 (thread-signal thread 'error nil) 298 (thread-signal thread 'error nil)
299 (sit-for 1) 299 (sit-for 1)
300 (should-not (thread-alive-p thread)) 300 (should-not (thread-live-p thread))
301 (should (equal (thread-last-error) '(error))))) 301 (should (equal (thread-last-error) '(error)))))
302 302
303(defvar threads-condvar nil) 303(defvar threads-condvar nil)
@@ -323,7 +323,7 @@
323 (setq new-thread (make-thread #'threads-test-condvar-wait)) 323 (setq new-thread (make-thread #'threads-test-condvar-wait))
324 324
325 ;; Make sure new-thread is alive. 325 ;; Make sure new-thread is alive.
326 (should (thread-alive-p new-thread)) 326 (should (thread-live-p new-thread))
327 (should (= (length (all-threads)) 2)) 327 (should (= (length (all-threads)) 2))
328 ;; Wait for new-thread to become blocked on the condvar. 328 ;; Wait for new-thread to become blocked on the condvar.
329 (while (not (eq (thread--blocker new-thread) threads-condvar)) 329 (while (not (eq (thread--blocker new-thread) threads-condvar))
@@ -336,7 +336,7 @@
336 (sleep-for 0.1) 336 (sleep-for 0.1)
337 ;; Make sure the thread is still there. This used to fail due to 337 ;; Make sure the thread is still there. This used to fail due to
338 ;; a bug in thread.c:condition_wait_callback. 338 ;; a bug in thread.c:condition_wait_callback.
339 (should (thread-alive-p new-thread)) 339 (should (thread-live-p new-thread))
340 (should (= (length (all-threads)) 2)) 340 (should (= (length (all-threads)) 2))
341 (should (eq (thread--blocker new-thread) threads-condvar)) 341 (should (eq (thread--blocker new-thread) threads-condvar))
342 342