I've decided to rename "virtual" flows to "monitor" flows.

This commit is contained in:
Tony Garnock-Jones 2012-07-04 16:36:03 -04:00
parent 9d069ab0f3
commit 84d769472b
6 changed files with 32 additions and 32 deletions

View File

@ -36,8 +36,8 @@
(w 'absence)
(w 'message)))
(transition 'spy-state
(add-role 's->p (topic-publisher (wild) #:virtual? #t) (hs 'subscriber->publisher))
(add-role 'p->s (topic-subscriber (wild) #:virtual? #t) (hs 'publisher->subscriber)))))
(add-role 's->p (topic-publisher (wild) #:monitor? #t) (hs 'subscriber->publisher))
(add-role 'p->s (topic-subscriber (wild) #:monitor? #t) (hs 'publisher->subscriber)))))
(ground-vm (lambda (boot-pid)
(transition 'no-state

View File

@ -18,12 +18,12 @@
(define (listener local-addr)
(transition 'no-state
(role 'inbound-handler (topic-subscriber (tcp-channel (wild) local-addr (wild)) #:virtual? #t)
(role 'inbound-handler (topic-subscriber (tcp-channel (wild) local-addr (wild)) #:monitor? #t)
#:state state
#:topic t
#:on-presence (match t
[(topic 'publisher (tcp-channel remote-addr (== local-addr) _) #t)
;; Ignore virtual flows. They just mean there's
;; Ignore monitor flows. They just mean there's
;; someone willing to supply connections to us
;; at some point in the future.
state]

View File

@ -24,12 +24,12 @@
(define (listener local-addr)
(transition 'no-state
(role 'inbound-handler (topic-subscriber (tcp-channel (wild) local-addr (wild)) #:virtual? #t)
(role 'inbound-handler (topic-subscriber (tcp-channel (wild) local-addr (wild)) #:monitor? #t)
#:state state
#:topic t
#:on-presence (match t
[(topic 'publisher (tcp-channel remote-addr (== local-addr) _) #t)
;; Ignore virtual flows. They just mean there's
;; Ignore monitor flows. They just mean there's
;; someone willing to supply connections to us
;; at some point in the future.
state]

View File

@ -84,15 +84,15 @@
(define tcp-driver
(transition (set)
(role 'tcp-listener-factory
(set (topic-subscriber (tcp-channel any-listener any-remote (wild)) #:virtual? #t)
(topic-publisher (tcp-channel any-remote any-listener (wild)) #:virtual? #t))
(set (topic-subscriber (tcp-channel any-listener any-remote (wild)) #:monitor? #t)
(topic-publisher (tcp-channel any-remote any-listener (wild)) #:monitor? #t))
#:state active-handles
#:topic t
#:on-presence (maybe-spawn-socket t active-handles tcp-listener-manager)
#:on-absence (maybe-forget-socket t active-handles))
(role 'tcp-connection-factory
(set (topic-subscriber (tcp-channel any-handle any-remote (wild)) #:virtual? #t)
(topic-publisher (tcp-channel any-remote any-handle (wild)) #:virtual? #t))
(set (topic-subscriber (tcp-channel any-handle any-remote (wild)) #:monitor? #t)
(topic-publisher (tcp-channel any-remote any-handle (wild)) #:monitor? #t))
#:state active-handles
#:topic t
#:on-presence (maybe-spawn-socket t active-handles tcp-connection-manager)
@ -128,8 +128,8 @@
(define listener (tcp:tcp-listen port 4 #t))
(transition 'listener-is-running
(role 'closer
(set (topic-subscriber (tcp-channel local-addr any-remote (wild)) #:virtual? #t)
(topic-publisher (tcp-channel any-remote local-addr (wild)) #:virtual? #t))
(set (topic-subscriber (tcp-channel local-addr any-remote (wild)) #:monitor? #t)
(topic-publisher (tcp-channel any-remote local-addr (wild)) #:monitor? #t))
#:state state
#:topic t
;; Hey, what if the presence we need went away between our
@ -246,8 +246,8 @@
(define tcp-spy
(transition 'no-state
(role 'tcp-pretty-printer
(set (topic-subscriber (wild) #:virtual? #t)
(topic-publisher (wild) #:virtual? #t))
(set (topic-subscriber (wild) #:monitor? #t)
(topic-publisher (wild) #:monitor? #t))
#:state state
[(tcp-channel source dest (? bytes? body))
(write `(TCPDATA ,source --> ,dest)) (newline)

View File

@ -49,23 +49,23 @@
(define udp-driver
(transition (set)
(role 'udp-socket-factory
(set (topic-publisher (udp-packet any-remote (udp-handle (wild)) (wild)) #:virtual? #t)
(topic-publisher (udp-packet any-remote (udp-listener (wild)) (wild)) #:virtual? #t)
(topic-subscriber (udp-packet any-remote (udp-handle (wild)) (wild)) #:virtual? #t)
(topic-subscriber (udp-packet any-remote (udp-listener (wild)) (wild)) #:virtual? #t))
(set (topic-publisher (udp-packet any-remote (udp-handle (wild)) (wild)) #:monitor? #t)
(topic-publisher (udp-packet any-remote (udp-listener (wild)) (wild)) #:monitor? #t)
(topic-subscriber (udp-packet any-remote (udp-handle (wild)) (wild)) #:monitor? #t)
(topic-subscriber (udp-packet any-remote (udp-listener (wild)) (wild)) #:monitor? #t))
#:state active-handles
#:topic t
#:on-presence (match t
[(topic _ (udp-packet _ local-addr _) counterparty-virtual?)
[(topic _ (udp-packet _ local-addr _) counterparty-monitor?)
(cond
[counterparty-virtual? active-handles]
[counterparty-monitor? active-handles]
[(set-member? active-handles local-addr) active-handles]
[else
(transition (set-add active-handles local-addr)
(spawn (udp-socket-manager local-addr)
#:debug-name (list 'udp-socket local-addr)))])]))
(role 'handle-mapping-reaper
(topic-subscriber (handle-mapping (wild) (wild)) #:virtual? #t)
(topic-subscriber (handle-mapping (wild) (wild)) #:monitor? #t)
#:state active-handles
#:topic t
#:on-absence (match t
@ -123,7 +123,7 @@
;; formatting.
(define udp-spy
(transition 'no-state
(role 'udp-pretty-printer (topic-subscriber (wild) #:virtual? #t)
(role 'udp-pretty-printer (topic-subscriber (wild) #:monitor? #t)
#:state state
[(udp-packet source dest body)
(write `(UDP ,source --> ,dest)) (newline)

20
os2.rkt
View File

@ -106,7 +106,7 @@
;; topics.
;; A sent message includes a "body" and a "role", and is equivalent to
;; a non-virtual topic with that role and with the given "body" as a
;; a non-monitor topic with that role and with the given "body" as a
;; pattern. In a sense, topics quite literally are patterns over
;; entire messages.
@ -140,7 +140,7 @@
;; A Topic is a (topic Role Pattern Boolean), describing an Endpoint's
;; role in a conversation.
(struct topic (role pattern virtual?) #:prefab)
(struct topic (role pattern monitor?) #:prefab)
;; BootSpecification = BootK or (boot-specification BootK Contract)
(struct boot-specification (proc contract) #:transparent)
@ -305,11 +305,11 @@
;;---------------------------------------------------------------------------
;; Topics and roles
(define (topic-publisher pattern #:virtual? [virtual? #f])
(topic 'publisher pattern virtual?))
(define (topic-publisher pattern #:monitor? [monitor? #f])
(topic 'publisher pattern monitor?))
(define (topic-subscriber pattern #:virtual? [virtual? #f])
(topic 'subscriber pattern virtual?))
(define (topic-subscriber pattern #:monitor? [monitor? #f])
(topic 'subscriber pattern monitor?))
;; TODO: Ideally this would be extensible; roles like 'debug-listener,
;; 'logger etc exist.
@ -341,11 +341,11 @@
;; True iff the flow between remote-topic and local-topic should be
;; visible to the local peer. This is the case when either local-topic
;; is virtual (in which case everything is seen) or otherwise if
;; remote-topic is also not virtual.
;; is a monitor (in which case everything is seen) or otherwise if
;; remote-topic is also not a monitor.
(define (flow-visible? local-topic remote-topic)
(or (topic-virtual? local-topic)
(not (topic-virtual? remote-topic))))
(or (topic-monitor? local-topic)
(not (topic-monitor? remote-topic))))
;;---------------------------------------------------------------------------
;; Composing state transitions and action emissions.