extend-ground-boot!

This commit is contained in:
Tony Garnock-Jones 2019-03-20 22:36:05 +00:00
parent 3ff50a6f65
commit 63ea6a9d3a
2 changed files with 12 additions and 7 deletions

View file

@ -24,9 +24,4 @@
(server-facet/websocket id scope))))
(module+ main
(let ((go (current-ground-dataspace)))
(current-ground-dataspace
(lambda (boot-proc)
(go (lambda ()
(boot-proc)
(main)))))))
(extend-ground-boot! main))

View file

@ -6,6 +6,7 @@
ground-assert!
ground-retract!
signal-background-activity!
extend-ground-boot!
run-ground)
(define-logger syndicate/ground)
@ -18,6 +19,7 @@
(require "syntax.rkt")
(define current-ground-event-async-channel (make-parameter #f))
(define *ground-boot-extensions* '())
(define (ground-enqueue! item)
(async-channel-put (current-ground-event-async-channel) item))
@ -34,6 +36,9 @@
(define (signal-background-activity! delta)
(ground-enqueue! delta))
(define (extend-ground-boot! proc)
(set! *ground-boot-extensions* (cons proc *ground-boot-extensions*)))
(define (run-ground* boot-proc)
(define ch (make-async-channel))
(parameterize ((current-ground-event-async-channel ch))
@ -67,7 +72,12 @@
(set! ground-event-relay-actor (current-actor))
;; v Adds a dummy endpoint to keep this actor alive
(begin/dataflow (void)))))
(schedule-script! (current-actor) boot-proc))))
(schedule-script! (current-actor)
(lambda ()
(boot-proc)
(let ((extensions (reverse *ground-boot-extensions*)))
(set! *ground-boot-extensions* '())
(for [(p (in-list extensions))] (p))))))))
(let loop ()
(define work-remaining? (run-scripts! ds))