Created
September 21, 2018 17:24
-
-
Save informatimago/7b874fbbfcb759ce2a1c1ca484728b40 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; https://www.axess-industries.com/casiers-consignes/armoire-casier-a-effet-personnel-p-150576-600x600.jpg | |
;; casier: a box protected by a lock! | |
(terpri) (ql:quickload :bordeaux-threads) | |
(defstruct casier | |
value | |
(lock (bt:make-lock))) | |
(defun (setf casier) (new-value casier) | |
(bt:with-lock-held ((casier-lock casier)) | |
(setf (casier-value casier) new-value))) | |
(defun casier (casier) | |
(bt:with-lock-held ((casier-lock casier)) | |
(casier-value casier))) | |
(defparameter *stop-worker-thread* (make-casier)) | |
(bt:make-thread (lambda () | |
(loop | |
:do (sleep 0.1) | |
(princ "+") | |
(finish-output) | |
:until (casier *stop-worker-thread*))) | |
:initial-bindings `((*standard-output* . ,*terminal-io*)) | |
:name "Test Casier") | |
(sleep 10) | |
(setf (casier *stop-worker-thread*) t) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment