cl-scopes/csys/csys.lisp

35 lines
1.1 KiB
Common Lisp

;;;; cl-scopes/csys - concurrent cybernetic communication systems
(defpackage :scopes/csys
(:use :common-lisp)
(:local-nicknames (:actor :scopes/core/actor)
(:async :scopes/util/async)
(:config :scopes/config)
(:core :scopes/core)
(:message :scopes/core/message)
(:shape :scopes/shape)
(:util :scopes/util)
(:alx :alexandria))
(:export #:*dispatcher* #:printer #:setup #:send
))
(in-package :scopes/csys)
(defun send (msg)
(let ((hdlrs (core:select msg (core:actions core:*root*))))
(if hdlrs
;(mapcar #'(lambda (hdlr) (run-action hdlr msg)) hdlrs)
(let ((tsks (mapcar (lambda (hdlr) (actor:create hdlr)) hdlrs)))
(dolist (tsk tsks) (actor:send tsk msg)))
(util:lgw "no action selected" msg))))
(defun run-action (job msg)
(let ((mb (async:make-task job)))
(async:submit-task mb (lambda () (funcall job msg)))))
;;;; example behaviors / actions
(defun printer (msg)
(util:lgi msg)
;(format t "~&~a" msg)
)