Provides and API

This commit is contained in:
Tony Garnock-Jones 2012-03-24 16:01:15 -04:00
parent 437ab6826d
commit a26fec6b1d
1 changed files with 42 additions and 1 deletions

43
os2.rkt
View File

@ -6,6 +6,33 @@
(require (only-in racket/list flatten))
(require "unify.rkt")
(provide nested-vm
ground-vm
(struct-out topic)
topic-publisher
topic-subscriber
co-roles
co-topics
(struct-out handlers)
(except-out (struct-out transition) transition)
(rename-out [make-transition transition])
extend-transition
(except-out (struct-out add-role) add-role)
(rename-out [make-add-role add-role])
(except-out (struct-out delete-role) delete-role)
(rename-out [make-delete-role delete-role])
(struct-out send-message)
(except-out (struct-out spawn) spawn)
(rename-out [make-spawn spawn])
(except-out (struct-out kill) kill)
(rename-out [make-kill kill])
(struct-out at-meta-level))
;; Endpoints are the units of deduplication.
;; Flows (in canonical form) are the units of presence.
@ -69,6 +96,19 @@
;; An Action is either a Preaction or an (at-meta-level Preaction).
(struct at-meta-level (preaction) #:prefab)
;;---------------------------------------------------------------------------
(define (make-transition state . actions) (transition state actions))
(define (make-add-role topic handlers [k #f]) (add-role topic handlers k))
(define (make-delete-role eid [reason #f]) (delete-role eid reason))
(define (make-spawn thunk [k #f]) (spawn thunk k))
(define (make-kill [pid #f] [reason #f]) (kill pid reason))
(define (extend-transition t . more-actions)
(match t
[(transition state actions) (transition state (list actions more-actions))]
[state (transition state more-actions)]))
;;---------------------------------------------------------------------------
;; Topics and roles
@ -307,7 +347,8 @@
(spawn thunk (wrap-trapk pid k))]
[(? kill?) preaction]))
;;---------------------------------------------------------------------------
(define (nested-vm boot)
(lambda () (run-vm (make-vm boot))))
(define (ground-vm boot)
(let run-kernel ((transition (run-vm (make-vm boot)))