entity/stop-on-retract
This commit is contained in:
parent
37ca805969
commit
bd65204760
|
@ -9,9 +9,9 @@
|
|||
|
||||
(define-logger syndicate/driver-support)
|
||||
|
||||
(define (linked-thread peer
|
||||
thread-proc
|
||||
(define (linked-thread thread-proc
|
||||
#:name [name (gensym 'linked-thread)]
|
||||
#:peer [peer (ref (entity/stop-on-retract #:name (list name 'monitor)))]
|
||||
#:custodian [c (make-custodian)])
|
||||
(define handle #f)
|
||||
(define armed? #t)
|
||||
|
|
|
@ -38,7 +38,6 @@
|
|||
(on-stop (log-syndicate/drivers/tcp-info "-listener on ~v ~v" host port))
|
||||
(linked-thread
|
||||
#:name (list (TcpInbound host port) 'thread)
|
||||
(ref (entity #:name 'listen-monitor #:retract (lambda (_handle) (stop-current-facet))))
|
||||
(lambda (facet)
|
||||
(define listener (tcp-listen port 512 #t host))
|
||||
(let loop ()
|
||||
|
@ -103,8 +102,6 @@
|
|||
(linked-thread
|
||||
#:name (list name 'input-thread)
|
||||
#:custodian custodian
|
||||
(ref (entity #:name (list name 'socket-monitor)
|
||||
#:retract (lambda (_handle) (stop-current-facet))))
|
||||
(lambda (facet)
|
||||
(let loop ()
|
||||
(define bs (read-bytes-avail i))
|
||||
|
|
|
@ -24,7 +24,6 @@
|
|||
|
||||
(linked-thread
|
||||
#:name 'timer-driver-thread
|
||||
(ref (entity #:name 'timer-monitor #:retract (lambda (_handle) (stop-current-facet))))
|
||||
(lambda (facet)
|
||||
(struct pending-timer (deadline label) #:transparent)
|
||||
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
begin/dataflow
|
||||
define/dataflow
|
||||
stop-when-true
|
||||
entity/stop-on-retract
|
||||
|
||||
this-target
|
||||
at
|
||||
|
@ -123,6 +124,9 @@
|
|||
(when test
|
||||
(stop-current-facet expr ...))))
|
||||
|
||||
(define (entity/stop-on-retract #:name [name 'stop-on-retract] [k void])
|
||||
(entity #:name name #:retract (lambda (_handle) (stop-current-facet (k)))))
|
||||
|
||||
;;---------------------------------------------------------------------------
|
||||
|
||||
(define-for-syntax orig-insp
|
||||
|
@ -217,15 +221,14 @@
|
|||
(match-define (list #,@(analyse-pattern-bindings #'pat)) bindings)
|
||||
(define name name-stx.N)
|
||||
(define monitor
|
||||
(ref (entity #:name (list name 'monitor-in-parent)
|
||||
#:retract (lambda (_handle) (stop-current-facet)))))
|
||||
(ref (entity/stop-on-retract #:name (list name 'monitor-in-parent))))
|
||||
(define monitor-handle (turn-assert! this-turn monitor 'alive))
|
||||
(turn-spawn! this-turn
|
||||
#:name name
|
||||
#:daemon? daemon.D
|
||||
#:link
|
||||
(entity #:name (list name 'monitor-in-child)
|
||||
#:retract (lambda (_handle) (stop-current-facet)))
|
||||
(entity/stop-on-retract #:name
|
||||
(list name 'monitor-in-child))
|
||||
(lambda () expr ...)
|
||||
(hasheq monitor-handle #t)))))))])))
|
||||
|
||||
|
|
Loading…
Reference in New Issue