actors: Rename ez-run-hive to run-hive.
[8sync.git] / 8sync / actors.scm
index 867e3d08e2e0a2d2525aa5d06189231c18648b99..333d779b6d6dea92e66d3f6db53ef1e382204920 100644 (file)
@@ -25,7 +25,6 @@
   #:use-module (ice-9 match)
   #:use-module (ice-9 pretty-print)
   #:use-module (8sync agenda)
-  #:use-module (8sync repl)
   #:export (;; utilities... ought to go in their own module
             big-random-number
             big-random-number-string
@@ -48,6 +47,8 @@
             actor-id-hive
             actor-id-string
 
+            actor-am-i-alive?
+
             build-actions
 
             define-simple-actor
@@ -74,7 +75,7 @@
 
             call-with-message msg-receive msg-val
 
-            ez-run-hive
+            run-hive
             bootstrap-message
 
             serialize-message write-message
@@ -295,15 +296,13 @@ raise an exception if an error."
                    ;; @@: There's no reason not to use #:class instead of
                    ;;   #:each-subclass anywhere in this file, except for
                    ;;   Guile bug #25211 (#:class is broken in Guile 2.2)
-                   #:allocation #:each-subclass)
+                   #:allocation #:each-subclass
+                   #:getter actor-message-handler)
 
   ;; This is the default, "simple" way to inherit and process messages.
   (actions #:init-value '()
            #:allocation #:each-subclass))
 
-(define-method (actor-message-handler (actor <actor>))
-  (slot-ref actor 'message-handler))
-
 ;;; So these are the nicer representations of addresses.
 ;;; However, they don't serialize so easily with scheme read/write, so we're
 ;;; using the simpler cons cell version below for now.
@@ -322,13 +321,13 @@ raise an exception if an error."
 ;;
 
 (define (make-address actor-id hive-id)
-  (cons actor-id hive-id))
+  (vector actor-id hive-id))
 
 (define (address-actor-id address)
-  (car address))
+  (vector-ref address 0))
 
 (define (address-hive-id address)
-  (cdr address))
+  (vector-ref address 1))
 
 (define (address->string address)
   (string-append (address-actor-id address) "@"
@@ -349,6 +348,9 @@ raise an exception if an error."
 (define %current-actor
   (make-parameter #f))
 
+(define (actor-am-i-alive? actor)
+  (hive-resolve-local-actor (actor-hive actor) (actor-id actor)))
+
 
 \f
 ;;; Actor utilities
@@ -632,6 +634,7 @@ that method for documentation."
                       init #f))
 
 (define* (hive-create-actor* hive actor-class id-cookie #:rest init)
+  "Create an actor, but also add a 'cookie' to the name for debugging"
   (%hive-create-actor hive actor-class
                       init id-cookie))
 
@@ -695,21 +698,11 @@ Like create-actor, but permits supplying an id-cookie."
 ;;; 8sync bootstrap utilities
 ;;; =========================
 
-(define* (ez-run-hive hive initial-tasks #:key repl-server)
-  "Start up an agenda and run HIVE in it with INITIAL-TASKS.
-
-Should we start up a cooperative REPL for live hacking?  REPL-SERVER
-wants to know!  You can pass it #t or #f, or if you want to specify a port,
-an integer."
+(define* (run-hive hive initial-tasks)
+  "Start up an agenda and run HIVE in it with INITIAL-TASKS."
   (let* ((queue (list->q initial-tasks))
          (agenda (make-agenda #:pre-unwind-handler print-error-and-continue
                               #:queue queue)))
-    (cond
-     ;; If repl-server is an integer, we'll use that as the port
-     ((integer? repl-server)
-      (spawn-and-queue-repl-server! agenda repl-server))
-     (repl-server
-      (spawn-and-queue-repl-server! agenda)))
     (start-agenda agenda)))
 
 (define (bootstrap-message hive to-id action . message-body-args)