(*package* *model-package*))
(eval netlogoed-lisp)))
+(defvar *commands-mutex* (sb-thread:make-mutex))
+
(defun run-commands (cmds)
"RUN-COMMANDS CMDS => RESULT
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
`((funcall ,netlogo-callback
(lambda (,(intern "NETLOGO-CODE" *model-package*))
,(netlogo-callback-body prims)))))
- ,@(when initialize-interface `((clnl-interface:initialize :dims ',(clnl-model:world-dimensions model)))))))))
+ ,@(when initialize-interface
+ `((clnl-interface:initialize
+ :dims ',(clnl-model:world-dimensions model)
+ :view ',(clnl-model:view 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
(clnl-model:set-current-interface ',(clnl-model:interface model))
(clnl-model:set-callback (symbol-function ',netlogo-callback-fn))
,(create-world-call model globals code-ast)
- ,@(when initialize-interface `((clnl-interface:initialize :dims ',(clnl-model:world-dimensions model)))))
+ ,@(when initialize-interface
+ `((clnl-interface:initialize
+ :dims ',(clnl-model:world-dimensions model)
+ :view ',(clnl-model:view 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))))))))