diff --git a/chat-os2-paper.rkt b/chat-os2-paper.rkt index 3f2b71a..651c3ca 100644 --- a/chat-os2-paper.rkt +++ b/chat-os2-paper.rkt @@ -38,7 +38,7 @@ (cin (tcp-credit 1)) (role out-t) (role in-t - #:on-absence (kill) + #:on-absence (quit) [(tcp-channel _ _ (? bytes? line)) (list (at-meta-level (cin (tcp-credit 1))) diff --git a/chat-os2.rkt b/chat-os2.rkt index a985ca3..fbda599 100644 --- a/chat-os2.rkt +++ b/chat-os2.rkt @@ -33,7 +33,7 @@ (cin (tcp-credit 1)) (role out-topic) (role in-topic - #:on-absence (kill) + #:on-absence (quit) [(tcp-channel _ _ (? bytes? line)) (list (at-meta-level (cin (tcp-credit 1))) (send-message `(,connection-id says ,line)))])))) diff --git a/os2-example.rkt b/os2-example.rkt index b4d0e26..90bfcd0 100644 --- a/os2-example.rkt +++ b/os2-example.rkt @@ -27,7 +27,7 @@ (error 'example-process "Oh noes!") (begin (write `(awoke after ,delay milliseconds)) (newline) - (transition state (kill))))))) + (transition state (quit))))))) (define spy (lambda (spy-pid) @@ -46,4 +46,4 @@ (spawn spy) (spawn (lambda (pid) (example-process 1000))) (spawn (lambda (pid) (example-process 2000))) - (kill)))) + (quit)))) diff --git a/os2-tcp-test-bytewise-echo.rkt b/os2-tcp-test-bytewise-echo.rkt index cbbd195..8fb84b2 100644 --- a/os2-tcp-test-bytewise-echo.rkt +++ b/os2-tcp-test-bytewise-echo.rkt @@ -15,7 +15,7 @@ (list (send-tcp-credit remote-addr local-addr 16) (send-message (tcp-channel local-addr remote-addr bs)))] [(tcp-channel remote _ (? eof-object?)) - (kill)])) + (quit)])) (transition 'no-state (send-tcp-credit remote-addr local-addr 16) diff --git a/os2-tcp-test-date-service.rkt b/os2-tcp-test-date-service.rkt index 1e7311e..f651996 100644 --- a/os2-tcp-test-date-service.rkt +++ b/os2-tcp-test-date-service.rkt @@ -10,7 +10,7 @@ (define ((connection-handler local-addr remote-addr) self-pid) (transition 'no-state (role (topic-publisher (tcp-channel local-addr remote-addr (wild))) - [(tcp-channel _ _ (tcp-credit _)) (kill)]) + [(tcp-channel _ _ (tcp-credit _)) (quit)]) (send-message (tcp-channel local-addr remote-addr (string->bytes/utf-8 (format "~a\n" (current-inexact-milliseconds))))))) diff --git a/os2-tcp-test-echo-service.rkt b/os2-tcp-test-echo-service.rkt index 84917d3..ed1fd82 100644 --- a/os2-tcp-test-echo-service.rkt +++ b/os2-tcp-test-echo-service.rkt @@ -17,7 +17,7 @@ (send-message (tcp-channel local-addr remote-addr (bytes-append #"You said: " line #"\n"))))] [(tcp-channel remote _ (? eof-object?)) - (kill)]))) + (quit)]))) (define (listener local-addr) (transition 'no-state diff --git a/os2-tcp.rkt b/os2-tcp.rkt index 5fd8779..dc85005 100644 --- a/os2-tcp.rkt +++ b/os2-tcp.rkt @@ -142,11 +142,11 @@ (if (ground? remote-addr) (transition state) (transition 'listener-is-closed - (kill) + (quit) (when (eq? state 'listener-is-running) (spawn (lambda (dummy-pid) (tcp:tcp-close listener) - (transition 'dummy (kill))) + (transition 'dummy (quit))) #:debug-name (list 'tcp-listener-closer local-addr)))))])) (role (topic-subscriber (cons (tcp:tcp-accept-evt listener) (wild))) #:state state @@ -171,14 +171,14 @@ (define (tcp-connection-manager* local-addr remote-addr cin cout) (define (close-transition state send-eof?) (transition #f - (kill) + (quit) (when (not (eq? state #f)) (list (when send-eof? (send-message (tcp-channel remote-addr local-addr eof))) (spawn (lambda (dummy-pid) (tcp:tcp-abandon-port cin) (tcp:tcp-abandon-port cout) - (transition 'dummy (kill))) + (transition 'dummy (quit))) #:debug-name (list 'tcp-connection-closer local-addr remote-addr)))))) (define (adjust-credit state amount) (let ((new-credit (+ (tcp-connection-state-credit state) amount))) diff --git a/os2-udp-test.rkt b/os2-udp-test.rkt index 67e42a7..6b65d4e 100644 --- a/os2-udp-test.rkt +++ b/os2-udp-test.rkt @@ -12,7 +12,7 @@ (topic-subscriber (udp-packet (wild) local-addr (wild)))) [(udp-packet source _ #"quit\n") (list (send-message (udp-packet local-addr source #"OK, quitting\n")) - (kill #:reason "Asked to quit"))] + (quit #:reason "Asked to quit"))] [(udp-packet source sink body) (send-message (udp-packet sink source body))])) diff --git a/os2-udp.rkt b/os2-udp.rkt index 7f24615..812b88e 100644 --- a/os2-udp.rkt +++ b/os2-udp.rkt @@ -94,11 +94,11 @@ (topic-subscriber (udp-packet local-addr any-remote (wild)))) #:state state #:on-absence (transition 'socket-is-closed - (kill) + (quit) (when (eq? state 'socket-is-open) (spawn (lambda (dummy-pid) (udp-close s) - (transition 'dummy (kill))) + (transition 'dummy (quit))) #:debug-name (list 'udp-socket-closer local-addr)))) [(udp-packet (== local-addr) (udp-address remote-host remote-port) body) (udp-send-to s remote-host remote-port body) diff --git a/os2.rkt b/os2.rkt index 3fffd5e..cc9c72b 100644 --- a/os2.rkt +++ b/os2.rkt @@ -45,8 +45,8 @@ send-feedback ;; TODO: maybe call this "send-reply" or "send-as-subscriber"? (except-out (struct-out spawn) spawn) (rename-out [make-spawn spawn]) - (except-out (struct-out kill) kill) - (rename-out [make-kill kill]) + (except-out (struct-out quit) quit) + (rename-out [make-quit quit]) (except-out (struct-out yield) yield) (rename-out [yield-macro yield]) (except-out (struct-out at-meta-level) at-meta-level) @@ -61,7 +61,7 @@ (rename-out [delete-role ]) (rename-out [send-message ]) (rename-out [spawn ]) - (rename-out [kill ]) + (rename-out [quit ]) (rename-out [yield ]) (rename-out [at-meta-level ]) @@ -176,7 +176,7 @@ (cond [(transition? t) t] [else (define message (format "maybe-transition->transition: Expected transition; got ~v" t)) - (transition #f (kill #f (exn:fail:contract message (current-continuation-marks))))])) + (transition #f (quit #f (exn:fail:contract message (current-continuation-marks))))])) ;; Preactions. ;; Ks are various TrapKs or #f, signifying lack of interest. @@ -193,15 +193,15 @@ ;; (spawn BootSpecification Maybe> Any) (struct spawn (spec k debug-name) #:prefab) ;; -;; (kill Maybe Any) -(struct kill (pid reason) #:prefab) +;; (quit Maybe Any) +(struct quit (pid reason) #:prefab) (define (preaction? a) (or (add-role? a) (delete-role? a) (send-message? a) (spawn? a) - (kill? a))) + (quit? a))) ;; An Action is either a Preaction or a (yield InterruptK) or an ;; (at-meta-level Preaction) or an ignored placeholder (namely #f or @@ -310,7 +310,7 @@ (define make-add-role add-role) ;; no special treatment required at present (define (make-delete-role pre-eid [reason #f]) (delete-role pre-eid reason)) (define (make-send-message body [role 'publisher]) (send-message body role)) -(define (make-kill [pid #f] #:reason [reason #f]) (kill pid reason)) +(define (make-quit [pid #f] #:reason [reason #f]) (quit pid reason)) (define (make-at-meta-level . actions) (match actions @@ -511,8 +511,8 @@ (values '() (route-and-deliver role body state))] [(spawn spec k debug-name) (values '() (do-spawn pid spec k debug-name state))] - [(kill pid-to-kill reason) - (do-kill (or pid-to-kill pid) reason state)])) + [(quit pid-to-quit reason) + (do-quit (or pid-to-quit pid) reason state)])) (define (topics-equal? ta tb) ;; TODO: OK, if we had a couple of simple topics here, we'd be done @@ -641,7 +641,7 @@ (match-define (transition initial-state initial-actions) (maybe-transition->transition (cond - [(procedure? main) (send-to-user (lambda (e) (transition #f (kill #f e))) main new-pid)] + [(procedure? main) (send-to-user (lambda (e) (transition #f (quit #f e))) main new-pid)] [else main]))) (define initial-process (process new-name new-pid @@ -657,43 +657,43 @@ (log-info (format "~a PID ~v (~a) started" (vm-name state) new-pid new-name)) (run-trapk spawned-state spawning-pid (list 'spawn 'k debug-name) k new-pid)) -(define (print-kill vm-name pid-to-kill process-name reason) +(define (print-quit vm-name pid-to-quit process-name reason) (cond [(eq? reason #f) (log-info (format "~a PID ~v (~a) exited normally" vm-name - pid-to-kill + pid-to-quit process-name))] [(exn? reason) (begin ((error-display-handler) (format "~a PID ~v (~a) exited with exception~n~a" vm-name - pid-to-kill + pid-to-quit process-name (exn-message reason)) reason) (flush-output (current-output-port)))] [else (log-info (format "~a PID ~v (~a) exited with reason: ~a" vm-name - pid-to-kill + pid-to-quit process-name reason))])) -(define (do-kill pid-to-kill reason state) +(define (do-quit pid-to-quit reason state) (cond - [(hash-has-key? (vm-processes state) pid-to-kill) - (define dying-process (hash-ref (vm-processes state) pid-to-kill)) - (print-kill (vm-name state) pid-to-kill (process-name dying-process) reason) + [(hash-has-key? (vm-processes state) pid-to-quit) + (define dying-process (hash-ref (vm-processes state) pid-to-quit)) + (print-quit (vm-name state) pid-to-quit (process-name dying-process) reason) (let* ((state (for/fold ([state state]) ([eid (in-set (process-endpoints dying-process))]) - (do-unsubscribe pid-to-kill (eid-pre-eid eid) reason state))) + (do-unsubscribe pid-to-quit (eid-pre-eid eid) reason state))) (new-outbound-actions (for/list ([eid (in-set (process-meta-endpoints dying-process))]) (delete-role eid reason)))) (values new-outbound-actions - (struct-copy vm state [processes (hash-remove (vm-processes state) pid-to-kill)])))] + (struct-copy vm state [processes (hash-remove (vm-processes state) pid-to-quit)])))] [else (values '() state)])) (define (run-trapk state pid new-party trap-k . args) (if trap-k (let ((failure-proc (lambda (e) (lambda (process-state) - (transition process-state (kill #f e)))))) + (transition process-state (quit #f e)))))) (run-ready state pid new-party (apply send-to-user failure-proc trap-k args))) state)) @@ -702,7 +702,7 @@ (hash-ref (vm-processes state) pid)) (match-define (transition new-state actions) (maybe-transition->transition - (send-to-user (lambda (e) (transition old-state (kill #f e))) + (send-to-user (lambda (e) (transition old-state (quit #f e))) (lambda () (interrupt-k (contract state-contract old-state old-party @@ -758,7 +758,7 @@ (wrap-trapk pid (list 'meta-spawn 'k debug-name) k) debug-name) state)] - [(? kill? p) + [(? quit? p) (values p state)])) (define-syntax nested-vm diff --git a/universe.rkt b/universe.rkt index 1f872d5..cb90412 100644 --- a/universe.rkt +++ b/universe.rkt @@ -50,14 +50,14 @@ (spawn (transition (ticker-state 0 rate-expr limit-expr) (role wild-sub #:state ts - ['stop (transition ts (kill))]) + ['stop (transition ts (quit))]) (let loop ((next-alarm-time 0)) (role (topic-subscriber (cons (time-evt next-alarm-time) (wild))) #:name 'tick-sequence #:state (and ts (ticker-state counter interval limit)) [(cons _ now) (if (and (positive? limit) (>= counter limit)) - (transition ts (kill)) + (transition ts (quit)) (transition (ticker-state (+ counter 1) interval limit) (delete-role 'tick-sequence) (loop (+ now (* 1000 interval))) @@ -102,7 +102,7 @@ #:state w ['stop (async-channel-put c:world->ui 'stop) - (transition w (kill))]) + (transition w (quit))]) (role wild-sub #:state w [`(render ,scene)