cs & thread: repair suspending a thread that is currently in sleep

Thanks to Greg Rosenblatt for the report.
This commit is contained in:
Matthew Flatt 2020-11-07 17:35:30 -07:00
parent db195a52b5
commit 7a12b4ac93
3 changed files with 13 additions and 1 deletions

View File

@ -1013,6 +1013,17 @@
(goes (lambda () (sync (system-idle-evt))) (lambda () (sync (system-idle-evt))) kill-thread))) (goes (lambda () (sync (system-idle-evt))) (lambda () (sync (system-idle-evt))) kill-thread)))
(list sleep void)) (list sleep void))
;; Suspend and sleep
(when (run-unreliable-tests? 'timing)
(let ([done? #f])
(define t (thread (lambda ()
(sleep 0.1)
(set! done? #t))))
(sync (system-idle-evt))
(thread-suspend t)
(sleep 0.1)
(test #f 'suspended-while-sleeping done?)))
;; ---------------------------------------- ;; ----------------------------------------
;; Simple multi-custodian threads ;; Simple multi-custodian threads

View File

@ -7663,7 +7663,7 @@
(void))))))) (void)))))))
(if (not (thread-descheduled? t_0)) (if (not (thread-descheduled? t_0))
(do-thread-deschedule! t_0 #f) (do-thread-deschedule! t_0 #f)
void))))) (begin (remove-from-sleeping-threads! t_0) void))))))
(define 1/thread-resume (define 1/thread-resume
(let ((thread-resume_0 (let ((thread-resume_0
(|#%name| (|#%name|

View File

@ -512,6 +512,7 @@
[(not (thread-descheduled? t)) [(not (thread-descheduled? t))
(do-thread-deschedule! t #f)] (do-thread-deschedule! t #f)]
[else [else
(remove-from-sleeping-threads! t)
void])])) void])]))
(define/who (thread-resume t [benefactor #f]) (define/who (thread-resume t [benefactor #f])