core/actor: first primitive implementation

This commit is contained in:
Helmut Merz 2025-04-13 10:13:04 +02:00
parent b4762d5003
commit 32913677fd
2 changed files with 11 additions and 3 deletions

View file

@ -4,7 +4,7 @@
(:use :common-lisp)
(:local-nicknames (:util :scopes/util))
(:export #:actor #:become #:create #:send
#:echo #:lgi))
#:echo #:inc #:lgi))
(in-package :scopes/core/actor)
@ -33,3 +33,9 @@
(defun echo (ac msg)
(send (customer msg) msg))
(defun inc (&optional (val 0))
#'(lambda (ac msg)
(if msg ; (payload msg)
(become ac (inc (+ msg val)))
(send (create #'lgi) val))))

View file

@ -128,8 +128,10 @@
(deftest test-actor ()
(let (a1 a2 a3)
(setf a1 (actor:create 'actor:lgi))
(actor:send a1 "Hello World")
(setf a1 (actor:create (actor:inc)))
(actor:send a1 2)
(actor:send a1 3)
(actor:send a1 nil)
))
(deftest test-send ()