csys, work in progress: environ:actions
This commit is contained in:
parent
b7546b3c0f
commit
20ed5134e5
3 changed files with 21 additions and 16 deletions
|
|
@ -9,9 +9,10 @@
|
|||
(:util :scopes/util)
|
||||
(:alx :alexandria))
|
||||
(:export #:scope #:environ
|
||||
#:neuron #:synapse #:std-proc #:update #:create
|
||||
#:make-prog
|
||||
#:handle-action))
|
||||
#:neuron #:std-proc #:create
|
||||
#:handle-action
|
||||
#:notify))
|
||||
|
||||
(in-package :scopes/csys)
|
||||
|
||||
|
|
@ -19,12 +20,12 @@
|
|||
|
||||
(defclass scope ()
|
||||
((value :accessor value :initarg :value :initform 0)
|
||||
(params :accessor params :initarg :params :initform nil) ; <- program
|
||||
;(params :accessor params :initarg :params :initform nil) ; <- program
|
||||
(categ :accessor categ :initarg :categ :initform '(:csys :c00))
|
||||
(stage :accessor stage :initform :initial)
|
||||
(proc :accessor proc :initarg :proc :initform #'std-proc)
|
||||
(program :reader program :initarg :program :initform nil)
|
||||
(actions :accessor actions :initarg :actions :initform nil) ; <- program
|
||||
;(actions :accessor actions :initarg :actions :initform nil) ; <- program
|
||||
(syns :accessor syns :initform nil)
|
||||
(environ :reader environ :initarg :environ)))
|
||||
|
||||
|
|
@ -43,8 +44,8 @@
|
|||
(setf (proc scope) (funcall (program scope) scope))
|
||||
scope)
|
||||
|
||||
(defun make-prog (fn)
|
||||
(lambda (scope) fn))
|
||||
(defgeneric make-prog (spec)
|
||||
(:method ((fn function)) (lambda (scope) fn)))
|
||||
|
||||
;;;; neurons (= async tasks) and synapses (= connections)
|
||||
|
||||
|
|
@ -66,7 +67,7 @@
|
|||
(defun std-proc (msg scope)
|
||||
;(util:lgi msg state syns env)
|
||||
(destructuring-bind (nmsg nscope)
|
||||
(handle-action msg scope :default #'remember)
|
||||
(handle-action msg scope :default #'remember) ; + params, actions
|
||||
(forward nmsg (syns nscope))
|
||||
(update nscope)))
|
||||
|
||||
|
|
@ -84,11 +85,11 @@
|
|||
(dolist (s syns)
|
||||
(funcall s msg)))
|
||||
|
||||
(defun handle-action (msg scope &key (default #'no-op))
|
||||
(defun handle-action (msg scope &key (default #'no-op) actions params)
|
||||
(let* ((key (message:action msg))
|
||||
;(act (select-action msg state default))
|
||||
(act (gethash key (actions scope) default)))
|
||||
(funcall act msg scope)))
|
||||
;(act (gethash key (actions scope) default))
|
||||
(act (getf actions key default)))
|
||||
(apply act msg scope params)))
|
||||
|
||||
(defun notify-created (msg new scope)
|
||||
(let* ((head (list (message:domain msg) :created))
|
||||
|
|
|
|||
|
|
@ -6,16 +6,20 @@
|
|||
(:csys :scopes/csys)
|
||||
(:message :scopes/core/message)
|
||||
)
|
||||
(:export #:forward)
|
||||
)
|
||||
(:export #:actions
|
||||
#:forward))
|
||||
|
||||
(in-package :scopes/csys/environ)
|
||||
|
||||
(defclass scope (csys:scope)
|
||||
((cells :reader cells :initarg :cells :initform (make-hash-table :test #'equal))))
|
||||
((cells :reader cells :initform (make-hash-table :test #'equal))))
|
||||
|
||||
;;;; action handlers, public callables
|
||||
|
||||
(defun actions ()
|
||||
'(:created #'cell-created
|
||||
:default #'csys:notify))
|
||||
|
||||
(defun cell-created (msg scope))
|
||||
|
||||
(defun forward-message (head scope &key data customer)
|
||||
|
|
|
|||
|
|
@ -35,8 +35,8 @@
|
|||
)
|
||||
|
||||
(defun proc-env (msg scope)
|
||||
(let ((t:*test-suite* (csys:environ scope)))
|
||||
(destructuring-bind (nmsg scope) (csys:handle-action msg scope)
|
||||
(let ((t:*test-suite* (csys:environ scope))) (destructuring-bind (nmsg scope)
|
||||
(csys:handle-action msg scope :actions (environ:actions))
|
||||
(util:lgi nmsg)
|
||||
(actor:send (core:mailbox (tc:receiver t:*test-suite*)) nmsg))))
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue