Avoid fiber deadlocks
Channels don't represent some channel on which messages travel, at least not a very long one because it can't accommodate any messages. They simply represent a direct exchange of the message between a sender and receiver. Because of this, put-message blocks the fiber, and if all the threads on the other end are waiting for replies to be received, then you have a deadlock. To avoid this situation, spawn new fibers to send the messages. I think this works at least, although I'm unsure how sensible it is.
This commit is contained in:
parent
55eaaaeeac
commit
96b65f16fb
1 changed files with 3 additions and 1 deletions
|
|
@ -99,7 +99,9 @@
|
||||||
(define (defer-to-thread-pool-channel thunk)
|
(define (defer-to-thread-pool-channel thunk)
|
||||||
(make-thread-pool-channel!)
|
(make-thread-pool-channel!)
|
||||||
(let ((reply (make-channel)))
|
(let ((reply (make-channel)))
|
||||||
(put-message %thread-pool-channel (cons reply thunk))
|
(spawn-fiber
|
||||||
|
(lambda ()
|
||||||
|
(put-message %thread-pool-channel (cons reply thunk))))
|
||||||
reply))
|
reply))
|
||||||
|
|
||||||
(define (fetch-result-of-defered-thunk reply-channel)
|
(define (fetch-result-of-defered-thunk reply-channel)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue