-
Notifications
You must be signed in to change notification settings - Fork 11
Description
At the moment, ^C causes Racket to signal an exn:break in a random Syndicate actor. This is perfectly backwards: we want the ground-vm to catch such signals and engage in a protocol to negotiate shutdown with the contained actors.
@howell's suggestion is fundamentally sound: change run-ground from (in essence) its current (loop) to (sync (thread (lambda () (loop)))). The reason for this is the (undocumented?) fact that exn:break is only ever delivered to the main Racket thread.
Complications: terminating the loop when the outer thread terminates, i.e., ensure a bidirectional connection; and implementing the protocol to allow actors to control break-based termination. A sketch of the whole thing:
(let ((outer-thread (current-thread)))
(with-handlers [(exn:break? (lambda (exn) (engage-in-protocol-with-contained-vm exn)))]
(sync (thread (lambda () (loop outer-thread))))))... where loop monitors outer-thread, terminating (without engaging in any kind of protocol) if it terminates.