forward messages via and additional neuron
This commit is contained in:
parent
be91b6a446
commit
2fd468e109
2 changed files with 14 additions and 7 deletions
11
csys.lisp
11
csys.lisp
|
@ -4,7 +4,8 @@
|
|||
(:use :common-lisp)
|
||||
(:local-nicknames (:actor :scopes/core/actor)
|
||||
(:util :scopes/util))
|
||||
(:export #:neuron #:synapse))
|
||||
(:export #:neuron #:synapse
|
||||
#:forward))
|
||||
|
||||
(in-package :decons/csys)
|
||||
|
||||
|
@ -14,4 +15,10 @@
|
|||
|
||||
(defun synapse (rcvr &optional (op #'identity))
|
||||
(lambda (msg)
|
||||
(actor:send rcvr (op msg))))
|
||||
(actor:send rcvr (funcall op msg))))
|
||||
|
||||
;;;; simple default / example neuron processors
|
||||
|
||||
(defun forward (msg state syns env)
|
||||
(dolist (s syns)
|
||||
(funcall s msg)))
|
||||
|
|
|
@ -9,11 +9,11 @@
|
|||
))
|
||||
|
||||
(deftest test-neuron ()
|
||||
(let ((prb (csys:neuron #'probe
|
||||
:state '(42 43)
|
||||
:env t:*test-suite*)))
|
||||
(actor:send prb (actor:message 42))
|
||||
(actor:send prb (actor:message 43))
|
||||
(let* ((prb (csys:neuron #'probe :env t:*test-suite* :state '(42 43)))
|
||||
(fw (csys:neuron #'csys:forward :syns (list (csys:synapse prb)))))
|
||||
(actor:send fw (actor:message 42))
|
||||
(actor:send fw (actor:message 43))
|
||||
(sleep 0.1)
|
||||
(actor:stop prb)
|
||||
(actor:stop fw)
|
||||
))
|
||||
|
|
Loading…
Add table
Reference in a new issue