I'm experimenting with using custodians to manage threads (on Racket 7.8
[cs]) and encountering behavior I don't understand.
I start a looping thread `t1` under a new custodian `c1`.
I then shutdown `c1` and expect `t1` to stop looping. If I started `t1`
with `thread` then this expectation is met. However, if I start it with
`thread/suspend-to-kill`, it continues looping even after `c1` is shut
down. Is this the correct behavior?
Additionally, I later start a new thread `t2` under a new custodian `c2`,
which attempts to resume `t1` after the shutdown, using itself as a
benefactor. However, `t1` does not seem to resume. Is this the correct
behavior?
Here is the code I'm working with:
```
#lang racket
(define c1 (make-custodian))
(define c2 (make-custodian))
(define t1 #f)
(define t2 #f)
(parameterize ((current-custodian c1))
;(set! t1 (thread/suspend-to-kill ;; (custodian-shutdown-all c1) fails
to suspend this thread
(set! t1 (thread
(lambda ()
(let loop ()
(displayln "thread 1")
(sleep 2)
(loop))))))
(displayln "ENTER to continue")
(read-line)
(custodian-shutdown-all c1)
(displayln "ENTER to continue")
(read-line)
(parameterize ((current-custodian c2))
(set! t2 (thread
(lambda ()
(thread-resume t1 (current-thread))
(let loop ()
(displayln "thread 2")
(sleep 2)
(loop))))))
(displayln "ENTER to continue")
(read-line)
(custodian-shutdown-all c2)
(displayln "ENTER to continue")
(read-line)
```
--
You received this message because you are subscribed to the Google Groups
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/racket-users/f844779f-9abd-46bd-987f-b2b3ca3d0925n%40googlegroups.com.