X-Git-Url: https://jxself.org/git/?p=8sync.git;a=blobdiff_plain;f=8sync%2Factors.scm;h=37f321bed89011f4e89b8bb6071d96ef3da9467c;hp=045a43a1ddc97dc9d9fb4f27767b4ac8edecfbd9;hb=08fb307989f2696ddbd2ad535f55558c577b2fdb;hpb=a5c16530d2e253c0d56143c5337740b1f7a403ed diff --git a/8sync/actors.scm b/8sync/actors.scm index 045a43a..37f321b 100644 --- a/8sync/actors.scm +++ b/8sync/actors.scm @@ -47,7 +47,7 @@ actor-id-hive actor-id-string - actor-am-i-alive? + actor-alive? build-actions @@ -358,7 +358,7 @@ to come after class definition." (define %current-actor (make-parameter #f)) -(define (actor-am-i-alive? actor) +(define (actor-alive? actor) (hive-resolve-local-actor (actor-hive actor) (actor-id actor))) @@ -440,7 +440,7 @@ to come after class definition." (define-method (hive-gen-actor-id (hive ) cookie) (make-address (if cookie - (string-append cookie "-" (big-random-number-string)) + (string-append cookie ":" (big-random-number-string)) (big-random-number-string)) (hive-id hive))) @@ -647,11 +647,13 @@ that method for documentation." actor-id)) (define* (hive-create-actor hive actor-class #:rest init) + "Create an actor on HIVE using ACTOR-CLASS passing in INIT args" (%hive-create-actor hive actor-class - init #f)) + init (symbol->string (class-name actor-class)))) (define* (hive-create-actor* hive actor-class id-cookie #:rest init) - "Create an actor, but also add a 'cookie' to the name for debugging" + "Create an actor, but also allow customizing a 'cookie' added to the id +for debugging" (%hive-create-actor hive actor-class init id-cookie)) @@ -705,8 +707,13 @@ Like create-actor, but permits supplying an id-cookie." init id-cookie)) -(define (self-destruct actor) - "Remove an actor from the hive." +(define* (self-destruct actor #:key (cleanup #t)) + "Remove an actor from the hive. + +Unless #:cleanup is set to #f, this will first have the actor handle +its '*cleanup* action handler." + (when cleanup + (<-wait actor (actor-id actor) '*cleanup*)) (hash-remove! (hive-actor-registry (actor-hive actor)) (actor-id actor))) @@ -715,7 +722,8 @@ Like create-actor, but permits supplying an id-cookie." ;;; 8sync bootstrap utilities ;;; ========================= -(define* (run-hive hive initial-tasks) +(define* (run-hive hive initial-tasks + #:key (cleanup #t)) "Start up an agenda and run HIVE in it with INITIAL-TASKS." (dynamic-wind (const #f) @@ -723,15 +731,16 @@ Like create-actor, but permits supplying an id-cookie." (let* ((queue (list->q initial-tasks)) (agenda (make-agenda #:pre-unwind-handler print-error-and-continue #:queue queue))) - (start-agenda agenda))) + (run-agenda agenda))) ;; Run cleanup (lambda () - (run-hive-cleanup hive)))) + (when cleanup + (run-hive-cleanup hive))))) (define (run-hive-cleanup hive) (let ((queue (list->q (list (bootstrap-message hive (actor-id hive) '*cleanup-all*))))) - (start-agenda + (run-agenda (make-agenda #:queue queue)))) (define (bootstrap-message hive to-id action . message-body-args)