X-Git-Url: https://jxself.org/git/?a=blobdiff_plain;f=8sync%2Finbox.scm;h=fbf8df08222310dfd2b74c4d6c8a088f9b54d62e;hb=refs%2Fheads%2Ffibers;hp=ad3bdfbe43f3e9fec23a0eeaacca9469ac03fe86;hpb=57b7dfc7a351017e09bd158889ed45fa57e51289;p=8sync.git diff --git a/8sync/inbox.scm b/8sync/inbox.scm index ad3bdfb..fbf8df0 100644 --- a/8sync/inbox.scm +++ b/8sync/inbox.scm @@ -25,30 +25,14 @@ #:use-module (ice-9 q) #:use-module (srfi srfi-9) #:use-module (ice-9 atomic) - #:export (spawn-inbox - delivery-agent)) + #:export (delivery-agent)) -(define* (spawn-inbox) - "Spawn an inbox fiber which manages a a buffered queue. - -Returns three values to its continuation: a INBOX-ENQ channel to send -messages to, an INBOX-DEQ channel which is what the actor doing the -reading should read from, and a STOP? atomic box which can be set to #t -to stop delivery." - (let ((inbox-enq (make-channel)) - (inbox-deq (make-channel)) - (stop? (make-atomic-box #f))) - (spawn-fiber (lambda () - ;; From the perspective of the delivery-agent, - ;; deliver-to - (delivery-agent inbox-enq inbox-deq stop?))) - (values inbox-enq inbox-deq stop?))) - -;; @@: Do we want to add a stop condition? +;; TODO: Add backpressure limit (define (delivery-agent inbox-enq inbox-deq stop?) "This starts up a loop doing delivery receiving from INBOX-ENQ and -delivering to INBOX-DEQ, actually managing an (ice-9 q) object QUEUE. -Atomic box STOP? can be set to indicate that this " +delivering to INBOX-DEQ, actually managing an internal object QUEUE. +Condidtion variable STOP? can be set to indicate that this agent +should stop." (define queue (make-q)) (define get-or-stop