Fix last change
* test/src/thread-tests.el (threads-condvar-wait): Revert previous change. Make sure no other threads from previous tests are running, to avoid interfering with our thread counts.
This commit is contained in:
parent
26b5426de8
commit
d018843e0e
1 changed files with 9 additions and 9 deletions
|
@ -257,14 +257,17 @@
|
|||
(ert-deftest threads-condvar-wait ()
|
||||
"test waiting on conditional variable"
|
||||
(let ((cv-mutex (make-mutex))
|
||||
(nthreads (length (all-threads)))
|
||||
new-thread)
|
||||
;; We could have spurious threads from the previous tests still
|
||||
;; running; wait for them to die.
|
||||
(while (> (length (all-threads)) 1)
|
||||
(thread-yield))
|
||||
(setq threads-condvar (make-condition-variable cv-mutex))
|
||||
(setq new-thread (make-thread #'threads-test-condvar-wait))
|
||||
|
||||
;; Make sure new-thread is alive.
|
||||
(should (thread-alive-p new-thread))
|
||||
(should (= (length (all-threads)) (1+ nthreads)))
|
||||
(should (= (length (all-threads)) 2))
|
||||
;; Wait for new-thread to become blocked on the condvar.
|
||||
(while (not (eq (thread--blocker new-thread) threads-condvar))
|
||||
(thread-yield))
|
||||
|
@ -272,21 +275,18 @@
|
|||
;; Notify the waiting thread.
|
||||
(with-mutex cv-mutex
|
||||
(condition-notify threads-condvar t))
|
||||
;; Allow new-thread to process the notification. Sleeping for too
|
||||
;; short time here will fail the length test below.
|
||||
(sleep-for 1)
|
||||
;; Allow new-thread to process the notification.
|
||||
(sleep-for 0.1)
|
||||
;; Make sure the thread is still there. This used to fail due to
|
||||
;; a bug in thread.c:condition_wait_callback.
|
||||
(should (thread-alive-p new-thread))
|
||||
(should (= (length (all-threads)) (1+ nthreads)))
|
||||
(should (memq new-thread (all-threads)))
|
||||
;; Make sure the other thread waits at the condition variable again.
|
||||
(should (= (length (all-threads)) 2))
|
||||
(should (eq (thread--blocker new-thread) threads-condvar))
|
||||
|
||||
;; Signal the thread.
|
||||
(thread-signal new-thread 'error '("Die, die, die!"))
|
||||
(sleep-for 0.1)
|
||||
;; Make sure the thread died.
|
||||
(should (= (length (all-threads)) nthreads))))
|
||||
(should (= (length (all-threads)) 1))))
|
||||
|
||||
;;; threads.el ends here
|
||||
|
|
Loading…
Add table
Reference in a new issue