X-Git-Url: https://jxself.org/git/?p=8sync.git;a=blobdiff_plain;f=8sync%2Fsystems%2Factors.scm;h=fd5391ad2e7c59bf40cdbae798088b7127350f4f;hp=f9b9047ac4a83fc1d06e82bb798422c0f7750dae;hb=e2d7d6de38565f0a7befe4e11b33206903568f3c;hpb=148aae4afbbbfa1a0845746294acb1385deda9b6 diff --git a/8sync/systems/actors.scm b/8sync/systems/actors.scm index f9b9047..fd5391a 100644 --- a/8sync/systems/actors.scm +++ b/8sync/systems/actors.scm @@ -171,6 +171,13 @@ If key not found and DFLT not provided, throw an error." dflt)))) +(define (message-needs-reply message) + "See if this message needs a reply still" + (and (message-wants-reply message) + (not (or (message-replied message) + (message-deferred-reply message))))) + + (define (kwarg-list-to-alist args) (let loop ((remaining args) (result '())) @@ -378,6 +385,7 @@ more compact following syntax: ;; This is a map from cons cell of message-id ;; to a cons cell of (actor-id . coroutine) ;; @@: Should we have a record type? + ;; @@: Should there be any way to clear out "old" coroutines? (waiting-coroutines #:init-thunk make-hash-table #:getter hive-waiting-coroutines) ;; Message prompt @@ -450,7 +458,18 @@ more compact following syntax: (lambda () (define message-handler (actor-message-handler actor)) ;; @@: Should a more general error handling happen here? - (message-handler actor message)) + (let ((result + (message-handler actor message))) + ;; Possibly autoreply + (if (message-needs-reply message) + (begin + ;; @@: Should we give *autoreply* as the action instead of *reply*? + (reply-message actor message + #:*auto-reply* #t))) + ;; Returning result allows actors to possibly make a run-request + ;; at the end of handling a message. + ;; ... We do want that, right? + result)) (lambda (kont actor message) (let ((hive (actor-hive actor)))