From 6b31b3323004f3dfa3705a546a78f2803e1e2217 Mon Sep 17 00:00:00 2001 From: Tony Garnock-Jones Date: Wed, 27 Jan 2016 21:03:08 -0500 Subject: [PATCH] Nameable demand-matchers --- prospect-monolithic/demand-matcher.rkt | 8 ++++++-- prospect/demand-matcher.rkt | 8 ++++++-- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/prospect-monolithic/demand-matcher.rkt b/prospect-monolithic/demand-matcher.rkt index 17558c6..c199b23 100644 --- a/prospect-monolithic/demand-matcher.rkt +++ b/prospect-monolithic/demand-matcher.rkt @@ -100,12 +100,14 @@ supply-spec increase-handler [decrease-handler unexpected-supply-decrease] + #:name [name #f] #:meta-level [meta-level 0]) (define d (make-demand-matcher (compile-projection (prepend-at-meta demand-spec meta-level)) (compile-projection (prepend-at-meta supply-spec meta-level)) (lambda (acs . rs) (cons (apply increase-handler rs) acs)) (lambda (acs . rs) (cons (apply decrease-handler rs) acs)))) - (spawn demand-matcher-handle-event + (spawn #:name name + demand-matcher-handle-event d (scn/union (subscription (projection->pattern demand-spec) #:meta-level meta-level) (subscription (projection->pattern supply-spec) #:meta-level meta-level) @@ -122,6 +124,7 @@ ;; quits. (define (on-claim #:timeout-msec [timeout-msec #f] #:on-timeout [timeout-handler (lambda () '())] + #:name [name #f] check-and-maybe-spawn-fn base-interests . projections) @@ -142,7 +145,8 @@ [_ #f])) (list (when timeout-msec (message (set-timer timer-id timeout-msec 'relative))) - (spawn on-claim-handler + (spawn #:name name + on-claim-handler (void) (scn/union base-interests (assertion-set-union* diff --git a/prospect/demand-matcher.rkt b/prospect/demand-matcher.rkt index 5762601..cf7a31e 100644 --- a/prospect/demand-matcher.rkt +++ b/prospect/demand-matcher.rkt @@ -96,12 +96,14 @@ supply-spec increase-handler [decrease-handler unexpected-supply-decrease] + #:name [name #f] #:meta-level [meta-level 0]) (define d (make-demand-matcher (compile-projection (prepend-at-meta demand-spec meta-level)) (compile-projection (prepend-at-meta supply-spec meta-level)) (lambda (acs . rs) (cons (apply increase-handler rs) acs)) (lambda (acs . rs) (cons (apply decrease-handler rs) acs)))) - (spawn demand-matcher-handle-event + (spawn #:name name + demand-matcher-handle-event d (patch-seq (sub (projection->pattern demand-spec) #:meta-level meta-level) (sub (projection->pattern supply-spec) #:meta-level meta-level) @@ -118,6 +120,7 @@ ;; quits. (define (on-claim #:timeout-msec [timeout-msec #f] #:on-timeout [timeout-handler (lambda () '())] + #:name [name #f] check-and-maybe-spawn-fn base-interests . projections) @@ -139,7 +142,8 @@ [_ #f])) (list (when timeout-msec (message (set-timer timer-id timeout-msec 'relative))) - (spawn on-claim-handler + (spawn #:name name + on-claim-handler (trie-empty) (patch-seq (patch base-interests (trie-empty)) (patch-seq* (map (lambda (p) (sub projection->pattern)) projections))