X-Git-Url: https://code.consxy.com/gitweb/gitweb.cgi?a=blobdiff_plain;f=src%2Fmain%2Fmain.lisp;h=4b845cff37d0b0a3b7f4b435a05a0e0b3d729ce2;hb=5f87a9fd0bed8832115f11073e5ee9a968ee95c0;hp=2f32d3b8b408c74ef7a41fff3cc3eee1f3dfb2f2;hpb=bc0c65622016066a82bc03b065f7138118c5b3cd;p=clnl diff --git a/src/main/main.lisp b/src/main/main.lisp index 2f32d3b..4b845cf 100644 --- a/src/main/main.lisp +++ b/src/main/main.lisp @@ -57,6 +57,8 @@ DESCRIPTION: (*package* *model-package*)) (eval netlogoed-lisp))) +(defvar *commands-mutex* (sb-thread:make-mutex)) + (defun run-commands (cmds) "RUN-COMMANDS CMDS => RESULT @@ -69,8 +71,11 @@ DESCRIPTION: RUN-COMMANDS will take NetLogo commands, put them through the various stages need to turn them into Common Lisp code, and run it." - (clnl-nvm:with-stop-handler - (funcall *callback* cmds))) + + ; This mutex is a necessary because we haven't yet moved to a job thread + (sb-thread:with-mutex (*commands-mutex*) + (clnl-nvm:with-stop-handler + (funcall *callback* cmds)))) (defun run-reporter (reporter) "RUN-REPORTER REPORTER => RESULT @@ -218,7 +223,8 @@ EXAMPLES: `((clnl-interface:initialize :dims ',(clnl-model:world-dimensions model) :view ',(clnl-model:view model) - :buttons ',(clnl-model:buttons model))))))))) + :buttons ',(clnl-model:buttons model) + :switches ',(clnl-model:switches model))))))))) (setf (documentation 'model->single-form-lisp 'function) "MODEL->SINGLE-FORM-LISP MODEL &key SEED INITIALIZE-INTERFACE NETLOGO-CALLBACK => FORM @@ -273,7 +279,8 @@ DESCRIPTION: `((clnl-interface:initialize :dims ',(clnl-model:world-dimensions model) :view ',(clnl-model:view model) - :buttons ',(clnl-model:buttons model))))) + :buttons ',(clnl-model:buttons model) + :switches ',(clnl-model:switches model))))) ,@(when netlogo-callback-fn `((defun ,netlogo-callback-fn (,(intern "NETLOGO-CODE" *model-package*)) ,(netlogo-callback-body prims))))))))