Replace one instance of yield with a use of wait-for.

This commit is contained in:
Tony Garnock-Jones 2012-07-04 17:39:35 -04:00
parent 3fe3bee397
commit f2046db35d
1 changed files with 15 additions and 6 deletions

View File

@ -133,6 +133,14 @@
(flush-output)
state]))
(define-syntax-rule (wait-for topic-of-interest #:state state action ...)
(let ((role-name (gensym 'wait-for)))
(role role-name topic-of-interest
#:state state
#:on-presence (sequence-actions state
(delete-role role-name)
action ...))))
(define (session-vm local-addr remote-addr)
(define local-identification #"SSH-2.0-RacketSSH_0.0")
@ -160,12 +168,13 @@
(spawn (ssh-writer local-addr remote-addr)
#:exit-signal? #t
#:debug-name 'ssh-writer)
;; (Wait for a cycle to let the reader and writer get
;; started, then tell the reader we are ready for a single
;; packet and spawn the session manager.)
;; TODO: try using presence instead of the yield.
(yield #:state state
(transition state
;; Wait for the reader and writer get started, then tell
;; the reader we are ready for a single packet and spawn
;; the session manager.
(wait-for (topic-subscriber (inbound-packet (wild) (wild) (wild) (wild)) #:monitor? #t)
#:state state
(wait-for (topic-publisher (outbound-packet (wild)) #:monitor? #t)
#:state state
(send-message (inbound-credit 1))
(spawn (ssh-session local-identification
remote-identification