diff --git a/os2.rkt b/os2.rkt index b00d136..356ec46 100644 --- a/os2.rkt +++ b/os2.rkt @@ -55,6 +55,9 @@ (rename-out [yield ]) (rename-out [at-meta-level ]) + (struct-out monitor) + spawn/monitor + ;; Reexports from unify.rkt for convenience wild wild? @@ -277,6 +280,24 @@ (or (topic-virtual? local-topic) (not (topic-virtual? remote-topic)))) +;;--------------------------------------------------------------------------- +;; Monitoring. + +(struct monitor (pid debug-name) #:prefab) + +(define (spawn/monitor main [k #f] #:debug-name [debug-name #f]) + ;; TODO: revisit the idea of points-of-attachment. There's an + ;; intermediate network between the processes and the kernel, and + ;; pid-level presence could be seen as object-level presence on that + ;; network somehow. + (define ((monitor-transition main-fn) self-pid) + (define m (monitor self-pid debug-name)) + (prefix-transition (main-fn self-pid) + (role (list 'canary m) (topic-publisher m) #:state state))) + (make-spawn (monitor-transition (if (procedure? main) main (lambda (self-pid) main))) + k + #:debug-name debug-name)) + ;;--------------------------------------------------------------------------- ;; Core virtualizable virtual machine.