fix lparallel:*kernel* creation - should not be set on load
This commit is contained in:
parent
41ed781a44
commit
20fb3acec5
2 changed files with 6 additions and 20 deletions
|
@ -9,13 +9,10 @@
|
||||||
#:message #:content #:customer #:set-content
|
#:message #:content #:customer #:set-content
|
||||||
#:*logger* #:*root*
|
#:*logger* #:*root*
|
||||||
#:echo #:inc #:lgi
|
#:echo #:inc #:lgi
|
||||||
#:calculator #:plus #:minus #:show #:send-value))
|
#:calculator #:plus #:minus #:show))
|
||||||
|
|
||||||
(in-package :scopes/core/actor)
|
(in-package :scopes/core/actor)
|
||||||
|
|
||||||
(eval-when (:compile-toplevel :load-toplevel :execute)
|
|
||||||
(async:init))
|
|
||||||
|
|
||||||
;;;; basic message implementation
|
;;;; basic message implementation
|
||||||
|
|
||||||
(defgeneric content (msg)
|
(defgeneric content (msg)
|
||||||
|
@ -60,7 +57,8 @@
|
||||||
|
|
||||||
(defun create (bhv)
|
(defun create (bhv)
|
||||||
(let ((mb (async:make-mb)))
|
(let ((mb (async:make-mb)))
|
||||||
(values mb (start mb bhv))))
|
(start mb bhv)
|
||||||
|
mb))
|
||||||
|
|
||||||
(defun send (mb msg)
|
(defun send (mb msg)
|
||||||
;(util:lgi msg)
|
;(util:lgi msg)
|
||||||
|
@ -76,15 +74,6 @@
|
||||||
(defun echo (msg)
|
(defun echo (msg)
|
||||||
(send (customer msg) 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
|
;;;; example behavior: calculator
|
||||||
|
|
||||||
(defun calculator (&optional (val 0))
|
(defun calculator (&optional (val 0))
|
||||||
|
@ -98,7 +87,5 @@
|
||||||
(defun minus (msg val param)
|
(defun minus (msg val param)
|
||||||
(calculator (- val param)))
|
(calculator (- val param)))
|
||||||
(defun show (msg 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)))
|
||||||
|
|
||||||
|
|
|
@ -115,17 +115,16 @@
|
||||||
(== (shape:head-value rec :username) :u1)))
|
(== (shape:head-value rec :username) :u1)))
|
||||||
|
|
||||||
(deftest test-actor ()
|
(deftest test-actor ()
|
||||||
;(async:init)
|
|
||||||
(let* ((calc (actor:create (actor:calculator)))
|
(let* ((calc (actor:create (actor:calculator)))
|
||||||
val
|
val
|
||||||
(collector
|
(collector
|
||||||
(actor:create (lambda (msg) (setf val (actor:content msg))))))
|
(actor:create (lambda (msg) (setf val (actor:content msg))))))
|
||||||
(actor:send calc (actor:message '(actor:plus 2)))
|
(actor:send calc (actor:message '(actor:plus 2)))
|
||||||
(actor:send calc (actor:message '(actor:minus 3)))
|
(actor:send calc (actor:message '(actor:minus 3)))
|
||||||
(actor:send calc (actor:message '(actor:show)))
|
|
||||||
(actor:send calc (actor:message '(actor:show) collector))
|
(actor:send calc (actor:message '(actor:show) collector))
|
||||||
|
(sleep 0.1)
|
||||||
(actor:stop calc)
|
(actor:stop calc)
|
||||||
(sleep 0.2)
|
(sleep 0.1)
|
||||||
(== val -1)
|
(== val -1)
|
||||||
))
|
))
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue