X-Git-Url: https://jxself.org/git/?a=blobdiff_plain;f=8sync%2Factors.scm;h=2c9870ce26aef93a51655e4206772dd632fce4f3;hb=47de7ccf21d3a2a615271d0ab007ce3d15ffa23d;hp=8aa38e325f5f2dfe6b79577d0d8ff5486dbcb666;hpb=bac7d5aece0b6687f7f55a235ae7c2969ea6d184;p=8sync.git diff --git a/8sync/actors.scm b/8sync/actors.scm index 8aa38e3..2c9870c 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 (clean-up #t)) + "Remove an actor from the hive. + +Unless #:clean-up is set to #f, this will first have the actor handle +its '*clean-up* action handler." + (when clean-up + (<-wait actor (actor-id actor) '*clean-up*)) (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 (clean-up #t)) "Start up an agenda and run HIVE in it with INITIAL-TASKS." (dynamic-wind (const #f) @@ -726,7 +734,8 @@ Like create-actor, but permits supplying an id-cookie." (start-agenda agenda))) ;; Run clean-up (lambda () - (run-hive-clean-up hive)))) + (when clean-up + (run-hive-clean-up hive))))) (define (run-hive-clean-up hive) (let ((queue (list->q (list (bootstrap-message hive (actor-id hive)