diff --git a/core/actor.lisp b/core/actor.lisp index 77c16bb..4f89af1 100644 --- a/core/actor.lisp +++ b/core/actor.lisp @@ -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)))) diff --git a/test/test-core.lisp b/test/test-core.lisp index 320887d..e4fad1f 100644 --- a/test/test-core.lisp +++ b/test/test-core.lisp @@ -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 ()