Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

^C handling and breaks #26

Open
tonyg opened this issue Aug 21, 2017 · 0 comments
Open

^C handling and breaks #26

tonyg opened this issue Aug 21, 2017 · 0 comments

Comments

@tonyg
Copy link
Owner

tonyg commented Aug 21, 2017

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant