Make both userland and big-bang able to spawn raw siblings
This commit is contained in:
parent
1fae9c95e3
commit
66f74dbe63
|
@ -11,6 +11,7 @@
|
|||
(struct-out send-message)
|
||||
(struct-out send-meta-message)
|
||||
(struct-out spawn)
|
||||
(struct-out spawn-raw)
|
||||
|
||||
(struct-out on-message)
|
||||
(struct-out on-meta-message)
|
||||
|
@ -31,11 +32,13 @@
|
|||
;; -- (send-message Message), to emit a message into the local medium
|
||||
;; -- (send-meta-message MetaMessage), to emit a message into the containing medium
|
||||
;; -- (spawn OtherWorldState ListOf<Action>), to start a new independent sibling in the local medium
|
||||
;; -- (spawn-raw BootK), to start a new sibling in the raw os.rkt eventing model
|
||||
(struct subscribe (sid event-description) #:transparent)
|
||||
(struct unsubscribe (sid) #:transparent)
|
||||
(struct send-message (body) #:transparent)
|
||||
(struct send-meta-message (body) #:transparent)
|
||||
(struct spawn (initial-state initial-actions) #:transparent)
|
||||
(struct spawn-raw (thunk) #:transparent)
|
||||
|
||||
;; An EventDescription is one of
|
||||
;; -- (on-message MessagePattern (Message WorldState -> Transition)), conditionally
|
||||
|
@ -102,7 +105,7 @@
|
|||
(send-message-body a))
|
||||
(for/list [(a actions) #:when (send-meta-message? a)]
|
||||
(send-meta-message-body a))
|
||||
(for/list [(a actions) #:when (spawn? a)]
|
||||
(for/list [(a actions) #:when (or (spawn? a) (spawn-raw? a))]
|
||||
(spawn->runnable a))))
|
||||
|
||||
(define (update-world w new-state actions)
|
||||
|
@ -120,8 +123,11 @@
|
|||
actions)))
|
||||
|
||||
(define (spawn->runnable s)
|
||||
(match-define (spawn initial-state initial-actions) s)
|
||||
(apply os-big-bang initial-state initial-actions))
|
||||
(match s
|
||||
[(spawn initial-state initial-actions)
|
||||
(apply os-big-bang initial-state initial-actions)]
|
||||
[(spawn-raw thunk)
|
||||
thunk]))
|
||||
|
||||
(define (os-big-bang initial-state . initial-actions)
|
||||
(lambda ()
|
||||
|
|
|
@ -18,7 +18,8 @@
|
|||
wait
|
||||
poll
|
||||
|
||||
spawn)
|
||||
spawn
|
||||
spawn-raw)
|
||||
|
||||
(struct wait-clause (pattern handler-proc) #:transparent)
|
||||
|
||||
|
@ -44,8 +45,7 @@
|
|||
(kernel-mode-transition sub
|
||||
(reverse messages)
|
||||
(reverse meta-messages)
|
||||
(map (lambda (t) (lambda () (userland t)))
|
||||
(reverse new-threads))))
|
||||
(reverse new-threads)))
|
||||
(match action
|
||||
[`(actions ,ms ,mms ,thrs ,k)
|
||||
(accumulate-transaction (append (reverse ms) messages)
|
||||
|
@ -93,4 +93,7 @@
|
|||
(call-in-kernel-context (lambda (k) `(wait #t ,mhs ,mmhs ,k))))
|
||||
|
||||
(define (spawn thunk)
|
||||
(spawn-raw (lambda () (userland thunk))))
|
||||
|
||||
(define (spawn-raw thunk)
|
||||
(actions '() '() (list thunk)))
|
||||
|
|
Loading…
Reference in New Issue