actor with restartable task now active (+ async fixes)

This commit is contained in:
Helmut Merz 2025-06-16 10:53:36 +02:00
parent b8dd5314e2
commit 02c8e68ced
2 changed files with 4 additions and 4 deletions

View file

@ -62,7 +62,7 @@
;;;; the core (classical, i.e. Hewitt) actor API
(defun create (bhv)
(let ((tsk (async:make-task bhv)))
(let ((tsk (async:make-task bhv :restartable t)))
(start tsk bhv)
tsk))
@ -99,7 +99,7 @@
(async:try-receive-result tsk)
(async:submit-task
tsk (lambda () (ac-loop tsk (async:behavior tsk)))))
(async:set-status :running)))
(async:set-status tsk :running)))
(defmethod set-bhv ((tsk async:task) bhv)
(setf (async:behavior tsk) bhv))
@ -120,7 +120,7 @@
(lambda (msg)
;(format t "calc ~a ~a~%" val (content msg))
(destructuring-bind (fn &optional param) (content msg)
(become (funcall fn msg val param)))))
(funcall fn msg val param))))
(defun plus (msg val param)
(calculator (+ val param)))

View file

@ -55,7 +55,7 @@
(defclass restartable-task (task)
((status :reader status
:initform (lp:make-channel :fixed-capacity 1 :initial-contents '(:new)))))
:initform (lpq:make-queue :fixed-capacity 1 :initial-contents '(:new)))))
(defun make-task (bhv &key restartable (cls 'task))
(if restartable (setf cls 'restartable-task))