cs: fix call-in-os-thread to not retain the current Racket thread
Closes #3843
This commit is contained in:
parent
0b8ea67bb3
commit
64b834c9c0
30
pkgs/racket-test/tests/racket/os-thread.rkt
Normal file
30
pkgs/racket-test/tests/racket/os-thread.rkt
Normal file
|
@ -0,0 +1,30 @@
|
|||
#lang racket/base
|
||||
(require ffi/unsafe
|
||||
ffi/unsafe/os-thread
|
||||
ffi/unsafe/os-async-channel)
|
||||
|
||||
(when (os-thread-enabled?)
|
||||
(define ch1 (make-os-async-channel))
|
||||
(define ch2 (make-os-async-channel))
|
||||
|
||||
(define wb
|
||||
(make-weak-box
|
||||
(thread (lambda ()
|
||||
(call-in-os-thread
|
||||
(lambda ()
|
||||
(os-async-channel-put ch1 'ready)
|
||||
(os-async-channel-get ch2)))
|
||||
(sync never-evt)))))
|
||||
|
||||
(sync (system-idle-evt))
|
||||
(os-async-channel-get ch1)
|
||||
|
||||
(collect-garbage)
|
||||
|
||||
(when (weak-box-value wb)
|
||||
(error "thread was retained"))
|
||||
|
||||
(os-async-channel-put ch2 'done)
|
||||
|
||||
'success)
|
||||
|
|
@ -15049,7 +15049,11 @@
|
|||
(if threaded? (void) (raise-unsupported 'unsafe-call-in-os-thread))
|
||||
(|#%app|
|
||||
fork-pthread
|
||||
(lambda () (begin (start-atomic) (|#%app| proc_0))))
|
||||
(lambda ()
|
||||
(begin
|
||||
(start-atomic)
|
||||
(current-thread/in-atomic #f)
|
||||
(|#%app| proc_0))))
|
||||
(void))))))
|
||||
(define finish_2628
|
||||
(make-struct-type-install-properties
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
#lang racket/base
|
||||
(require "check.rkt"
|
||||
"host.rkt"
|
||||
"atomic.rkt")
|
||||
"atomic.rkt"
|
||||
"parameter.rkt")
|
||||
|
||||
(provide unsafe-os-thread-enabled?
|
||||
unsafe-call-in-os-thread
|
||||
|
@ -17,6 +18,7 @@
|
|||
(unless threaded? (raise-unsupported who))
|
||||
(fork-pthread (lambda ()
|
||||
(start-atomic) ; just in case
|
||||
(current-thread/in-atomic #f) ; don't inherit
|
||||
(proc)))
|
||||
(void))
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user