cl-scopes/csys/csys.lisp

39 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* #:setup #:start
#:printer
))
(in-package :scopes/csys)
(defvar *dispatcher* nil)
(defun setup (&optional (cfg config:*root*))
(setf *dispatcher* (make-instance 'core:context :config cfg))
(setf (core:mailbox *dispatcher*) (async:make-mb))
(dolist (a (config:actions cfg))
(core:add-action *dispatcher* (car a) (cadr a))))
(defun start ()
(async:init)
(actor:start (core:mailbox *dispatcher*)
(lambda (msg) (funcall #'handle-message msg))
:foreground t))
(defun handle-message (msg)
(print msg))
;;;; example behaviors / actions
(defun printer (msg)
(print msg))