diff --git a/core/actor.lisp b/core/actor.lisp index 626b6f2..babcc20 100644 --- a/core/actor.lisp +++ b/core/actor.lisp @@ -9,13 +9,10 @@ #:message #:content #:customer #:set-content #:*logger* #:*root* #:echo #:inc #:lgi - #:calculator #:plus #:minus #:show #:send-value)) + #:calculator #:plus #:minus #:show)) (in-package :scopes/core/actor) -(eval-when (:compile-toplevel :load-toplevel :execute) - (async:init)) - ;;;; basic message implementation (defgeneric content (msg) @@ -60,7 +57,8 @@ (defun create (bhv) (let ((mb (async:make-mb))) - (values mb (start mb bhv)))) + (start mb bhv) + mb)) (defun send (mb msg) ;(util:lgi msg) @@ -76,15 +74,6 @@ (defun echo (msg) (send (customer msg) msg)) -;;;; predefined global actors - -(defvar *logger* (create #'lgi)) - -(defun root-bhv (ac msg) - (send *logger* msg)) - -(defvar *root* (create #'root-bhv)) - ;;;; example behavior: calculator (defun calculator (&optional (val 0)) @@ -98,7 +87,5 @@ (defun minus (msg val param) (calculator (- val param))) (defun show (msg val param) - (send (or (customer msg) *logger*) (message val))) -(defun send-value (msg val param) - (send (customer msg) (message val))) + (send (customer msg ) (message val))) diff --git a/test/test-core.lisp b/test/test-core.lisp index 9f414fd..49b7cd0 100644 --- a/test/test-core.lisp +++ b/test/test-core.lisp @@ -115,17 +115,16 @@ (== (shape:head-value rec :username) :u1))) (deftest test-actor () - ;(async:init) (let* ((calc (actor:create (actor:calculator))) val (collector (actor:create (lambda (msg) (setf val (actor:content msg)))))) (actor:send calc (actor:message '(actor:plus 2))) (actor:send calc (actor:message '(actor:minus 3))) - (actor:send calc (actor:message '(actor:show))) (actor:send calc (actor:message '(actor:show) collector)) + (sleep 0.1) (actor:stop calc) - (sleep 0.2) + (sleep 0.1) (== val -1) ))