I am most probably abusing cl-gserver here but I was trying to test breaking up a long running task into many actors but all the sub actors dont complete their futures. Is it a bug or am I really messing up. (Just as a note I tried to create the sub actors as actors of the system or as actors of the main actor and the result is the same.)
There is a break in the code to show where things get stuck.
(defparameter *system* (asys:make-actor-system))
(defun blocking-task-spread-work ()
;;Message processing is blocked untill the main task is returned,
;;The actual work is split between many actors and we wait for all of them
;;to finish
(let ((blocking-actor
(ac:actor-of
*system*
(lambda ()
(act:make-actor
(lambda (self msg state)
(let ((output (get-universal-time)))
(format t "~a : ~a : ~a~%" (act-cell:name self) msg output)
(if state
(cons output state)
(progn
(let ((futures))
(dotimes (i 5)
(push
(act:ask
(ac:actor-of (act:context self)
(lambda ()
(act:make-actor
(lambda (child-self msg state)
(declare (ignore child-self))
(let ((output msg))
(format t "~a : ~a~%" (act-cell:name self) output)
(sleep 1)
(cons output state)))
:name (format nil "child-~A" i))))
"Load Shard")
futures))
(loop do (break "~A" futures)
until (every #'future:complete-p futures)))
(cons output t)))))
:name "long-task")))))
(future:on-completed
(act:ask blocking-actor "Load shards" )
(lambda (result)
(format t "Received final result: ~a~%" result)))
(ac:stop *system* blocking-actor)))
(blocking-task-spread-work)