Sketchy role handler update. Pragmatic, rather than principled.
This commit is contained in:
parent
ee1ec3ceda
commit
cabdd27917
30
os2.rkt
30
os2.rkt
|
@ -343,15 +343,37 @@
|
|||
[(kill pid-to-kill reason)
|
||||
(do-kill (or pid-to-kill pid) reason state)]))
|
||||
|
||||
(define (topics-equal? ta tb)
|
||||
;; TODO: OK, if we had a couple of simple topics here, we'd be done
|
||||
;; by asking (and (specialization? ta tb) (specialization? tb ta)),
|
||||
;; but because we have sets of implicitly-unioned topics, things get
|
||||
;; jolly awkward. For now, we punt, trusting the user to not supply
|
||||
;; an incompatible set of topics on an endpoint update. This is
|
||||
;; definitely an interim position: full presence will require a
|
||||
;; serious treatment of topic unions via anti-unification.
|
||||
#t)
|
||||
|
||||
(define (do-subscribe pid pre-eid topics hs state)
|
||||
(cond
|
||||
[(hash-has-key? (vm-processes state) pid)
|
||||
(define new-eid (eid pid pre-eid))
|
||||
(define old-endpoint (hash-ref (vm-endpoints state) new-eid #f))
|
||||
(define new-endpoint (endpoint new-eid topics hs))
|
||||
(let* ((state (notify-route-additions state new-endpoint))
|
||||
(state (generic-update-process state pid (add-process-eid new-eid)))
|
||||
(state (install-endpoint state new-eid new-endpoint)))
|
||||
state)]
|
||||
(if old-endpoint
|
||||
;; We are *updating* an existing endpoint's behaviour.
|
||||
(if (topics-equal? (endpoint-topics old-endpoint)
|
||||
(endpoint-topics new-endpoint))
|
||||
(let* ((state (install-endpoint state new-eid new-endpoint)))
|
||||
state)
|
||||
(error 'do-subscribe
|
||||
"Topics must be equal when updating an endpoint: ~v vs ~v"
|
||||
old-endpoint
|
||||
new-endpoint))
|
||||
;; We are installing a *new* endpoint.
|
||||
(let* ((state (notify-route-additions state new-endpoint))
|
||||
(state (generic-update-process state pid (add-process-eid new-eid)))
|
||||
(state (install-endpoint state new-eid new-endpoint)))
|
||||
state))]
|
||||
[else state]))
|
||||
|
||||
(define (generic-update-process state pid updater)
|
||||
|
|
Loading…
Reference in New Issue