core/actor: first primitive implementation
This commit is contained in:
parent
b4762d5003
commit
32913677fd
2 changed files with 11 additions and 3 deletions
|
@ -4,7 +4,7 @@
|
||||||
(:use :common-lisp)
|
(:use :common-lisp)
|
||||||
(:local-nicknames (:util :scopes/util))
|
(:local-nicknames (:util :scopes/util))
|
||||||
(:export #:actor #:become #:create #:send
|
(:export #:actor #:become #:create #:send
|
||||||
#:echo #:lgi))
|
#:echo #:inc #:lgi))
|
||||||
|
|
||||||
(in-package :scopes/core/actor)
|
(in-package :scopes/core/actor)
|
||||||
|
|
||||||
|
@ -33,3 +33,9 @@
|
||||||
|
|
||||||
(defun echo (ac msg)
|
(defun echo (ac msg)
|
||||||
(send (customer msg) 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))))
|
||||||
|
|
|
@ -128,8 +128,10 @@
|
||||||
|
|
||||||
(deftest test-actor ()
|
(deftest test-actor ()
|
||||||
(let (a1 a2 a3)
|
(let (a1 a2 a3)
|
||||||
(setf a1 (actor:create 'actor:lgi))
|
(setf a1 (actor:create (actor:inc)))
|
||||||
(actor:send a1 "Hello World")
|
(actor:send a1 2)
|
||||||
|
(actor:send a1 3)
|
||||||
|
(actor:send a1 nil)
|
||||||
))
|
))
|
||||||
|
|
||||||
(deftest test-send ()
|
(deftest test-send ()
|
||||||
|
|
Loading…
Add table
Reference in a new issue