actors: Reflect removal of choice of whether to cleanup in self-destruct
[8sync.git] / demos / actors / botherbotherbother.scm
index 3bd30a4cfd9f2cc0d141de5ffc96a1fc441ac71a..57b20ff22a78abd9d6b2c685b3073969856d5aab 100755 (executable)
 
 ;; Puppet show simulator.
 
-(use-modules (8sync agenda)
-             (8sync actors)
+(use-modules (8sync actors)
              (oop goops)
              (ice-9 hash-table)
-             (ice-9 format))
+             (ice-9 format)
+             (fibers conditions))
 
 (set! *random-state* (random-state-from-platform))
 (define (random-choice lst)
 (define num-students 10)
 
 (define (main . args)
-  (define agenda (make-agenda))
-  (define hive (make-hive))
-  (define professor (bootstrap-actor* hive <professor> "prof"))
-  (define namegen (student-name-generator))
-  (define students
-    (map
-     (lambda _
-       (let ((name (namegen)))
-         (bootstrap-actor* hive <student> name
+  (run-hive
+   (lambda (hive)
+     (define professor (create-actor* <professor> "prof"))
+     (define namegen (student-name-generator))
+     (define students
+       (map
+        (lambda _
+          (let ((name (namegen)))
+            (create-actor* <student> name
                            #:name name)))
-     (iota num-students)))
-
-  ;; Bootstrap each student into bothering-professor mode.
-  (define start-bothering-tasks
-    (map
-     (lambda (student)
-       (bootstrap-message hive student 'bother-professor
-                               #:target professor))
-     students))
-
-  (run-hive hive start-bothering-tasks))
+        (iota num-students)))
+
+     ;; Bootstrap each student into bothering-professor mode.
+     (define start-bothering-tasks
+       (map
+        (lambda (student)
+          (<- student 'bother-professor
+              #:target professor))
+        students))
+
+     (run-hive hive start-bothering-tasks)
+     ;; in other words, this program doesn't really halt
+     (wait (make-condition)))))