From e4d9ab9fd070b51d5de757e1defaba5ade59554b Mon Sep 17 00:00:00 2001 From: cage Date: Sun, 11 Feb 2024 15:08:16 +0100 Subject: [PATCH] - replaced occurences of 'with-lock' with 'misc:with-lock-held'. --- src/gemini-viewer.lisp | 14 +++++++------- src/gui/client/json-rpc-communication.lisp | 2 +- src/gui/client/main-window.lisp | 16 ++++++++-------- src/gui/client/program-events.lisp | 6 +++--- src/program-events.lisp | 14 +++++++------- src/tests/program-events-tests.lisp | 2 +- src/ui-goodies.lisp | 2 +- 7 files changed, 28 insertions(+), 28 deletions(-) diff --git a/src/gemini-viewer.lisp b/src/gemini-viewer.lisp index 3e49734..5a335d2 100644 --- a/src/gemini-viewer.lisp +++ b/src/gemini-viewer.lisp @@ -51,7 +51,7 @@ (find-db-stream-if (lambda (a) (string= (download-iri a) url)))) (defun ensure-just-one-stream-rendering () - (with-lock (*gemini-db-streams-lock*) + (with-lock-held (*gemini-db-streams-lock*) (when-let ((current-rendering (find-db-stream-if (lambda (a) (eq (stream-status a) :rendering))))) @@ -226,28 +226,28 @@ (defmethod abort-downloading ((object gemini-stream)) (with-accessors ((download-thread-lock download-thread-lock)) object (setf (stream-status object) :aborted) - (with-lock (download-thread-lock) + (with-lock-held (download-thread-lock) (setf (download-thread-blocked object) t)))) (defmethod allow-downloading ((object gemini-stream)) (with-accessors ((download-thread-lock download-thread-lock)) object - (with-lock (download-thread-lock) + (with-lock-held (download-thread-lock) (setf (download-thread-blocked object) nil)))) (defmethod downloading-allowed-p ((object gemini-stream)) (with-accessors ((download-thread-lock download-thread-lock)) object - (with-lock (download-thread-lock) + (with-lock-held (download-thread-lock) (not (download-thread-blocked-p object))))) (defmethod (setf stream-status) (val (object gemini-stream)) (with-accessors ((download-thread-lock download-thread-lock) (stream-status stream-status)) object - (with-lock (download-thread-lock) + (with-lock-held (download-thread-lock) (setf (slot-value object 'stream-status) val)))) (defmethod stream-status ((object gemini-stream)) (with-accessors ((download-thread-lock download-thread-lock)) object - (with-lock (download-thread-lock) + (with-lock-held (download-thread-lock) (slot-value object 'stream-status)))) (defmethod downloading-start-thread ((object gemini-stream) @@ -276,7 +276,7 @@ (with-accessors ((download-thread-lock download-thread-lock) (support-file support-file) (parsed-lines parsed-lines)) object - (with-lock (download-thread-lock) + (with-lock-held (download-thread-lock) (gemini-parser:with-initialized-parser (let ((event (make-gemini-download-event (fs:slurp-file support-file) parsed-lines diff --git a/src/gui/client/json-rpc-communication.lisp b/src/gui/client/json-rpc-communication.lisp index 595912e..b9d3231 100644 --- a/src/gui/client/json-rpc-communication.lisp +++ b/src/gui/client/json-rpc-communication.lisp @@ -50,7 +50,7 @@ (defgeneric make-request (method id &rest args)) (defmethod make-request ((method symbol) id &rest args) - (misc:with-lock (*request-lock*) + (misc:with-lock-held (*request-lock*) (apply #'make-request (string-downcase (symbol-name method)) id args))) (define-condition rpc-error-response (conditions:text-error) diff --git a/src/gui/client/main-window.lisp b/src/gui/client/main-window.lisp index 07ff0f0..4e35e6d 100644 --- a/src/gui/client/main-window.lisp +++ b/src/gui/client/main-window.lisp @@ -24,11 +24,11 @@ (defgeneric streaming-url (object)) (defmethod status ((object gemini-stream)) - (misc:with-lock ((status-lock object)) + (misc:with-lock-held ((status-lock object)) (slot-value object 'status))) (defmethod (setf status) ((object gemini-stream) val) - (misc:with-lock ((status-lock object)) + (misc:with-lock-held ((status-lock object)) (setf (slot-value object 'status) val) val)) @@ -40,7 +40,7 @@ (defparameter *gemini-streams-db-lock* (make-lock "gemini-streams-db-lock")) (defun push-db-stream (stream-object) - (misc:with-lock (*gemini-streams-db-lock*) + (misc:with-lock-held (*gemini-streams-db-lock*) (pushnew stream-object *gemini-streams-db* :test (lambda (a b) @@ -49,7 +49,7 @@ *gemini-streams-db*)) (defun remove-db-stream (stream-object) - (misc:with-lock (*gemini-streams-db-lock*) + (misc:with-lock-held (*gemini-streams-db-lock*) (setf *gemini-streams-db* (remove stream-object *gemini-streams-db*)) *gemini-streams-db*)) @@ -58,7 +58,7 @@ (setf (status object) +stream-status-canceled+)) (defun remove-all-db-stream () - (misc:with-lock (*gemini-streams-db-lock*) + (misc:with-lock-held (*gemini-streams-db-lock*) (map nil (lambda (a) (abort-downloading a)) *gemini-streams-db*) @@ -66,7 +66,7 @@ *gemini-streams-db*)) (defun find-db-stream-if (predicate) - (misc:with-lock (*gemini-streams-db-lock*) + (misc:with-lock-held (*gemini-streams-db-lock*) (find-if predicate *gemini-streams-db*))) (defun find-db-stream-url (url) @@ -1519,11 +1519,11 @@ local file paths." (defgeneric fit-toc-char-width (object new-width)) (defmethod interrupt-rendering-p ((object main-frame)) - (misc:with-lock ((interrupt-rendering-lock object)) + (misc:with-lock-held ((interrupt-rendering-lock object)) (slot-value object 'interrupt-rendering))) (defun set-interrupt-rendering-state (main-frame value) - (misc:with-lock ((interrupt-rendering-lock main-frame)) + (misc:with-lock-held ((interrupt-rendering-lock main-frame)) (setf (slot-value main-frame 'interrupt-rendering) value))) (defmethod interrupt-rendering ((object main-frame)) diff --git a/src/gui/client/program-events.lisp b/src/gui/client/program-events.lisp index b0fa5ee..52718b8 100644 --- a/src/gui/client/program-events.lisp +++ b/src/gui/client/program-events.lisp @@ -7,11 +7,11 @@ (defparameter *events-loop-thread* nil) (defun events-loop-running-p () - (misc:with-lock (*events-loop-lock*) + (misc:with-lock-held (*events-loop-lock*) (not *stop-events-loop*))) (defun stop-events-loop () - (misc:with-lock (*events-loop-lock*) + (misc:with-lock-held (*events-loop-lock*) (setf *stop-events-loop* t)) #+debug-mode (misc:dbg "Stopping gui event thread") (ev:with-enqueued-process-and-unblock () @@ -19,7 +19,7 @@ #+debug-mode (misc:dbg "Stopped gui event thread")) (defun start-events-loop () - (misc:with-lock (*events-loop-lock*) + (misc:with-lock-held (*events-loop-lock*) (setf *stop-events-loop* nil)) (setf *events-loop-thread* (make-thread (lambda () diff --git a/src/program-events.lisp b/src/program-events.lisp index c3b4040..aa99e29 100644 --- a/src/program-events.lisp +++ b/src/program-events.lisp @@ -95,7 +95,7 @@ (defmacro wrapped-in-lock ((queue) &body body) (with-gensyms (lock) `(with-accessors ((,lock lock)) ,queue - (with-lock (,lock) + (with-lock-held (,lock) ,@body)))) (defclass events-queue (priority-queue) @@ -152,7 +152,7 @@ object)) (defun pop-event-block () - (with-lock ((blocking-lock *events-queue*)) + (with-lock-held ((blocking-lock *events-queue*)) (loop while (emptyp *events-queue*) do (condition-wait (condition-variable *events-queue*) @@ -160,7 +160,7 @@ (pop-element *events-queue*))) (defun push-event-unblock (value) - (with-lock ((blocking-lock *events-queue*)) + (with-lock-held ((blocking-lock *events-queue*)) (push-element *events-queue* value) (condition-notify (condition-variable *events-queue*)))) @@ -249,11 +249,11 @@ (handler-case (progn (setf (box:unbox results) (funcall callback)) - (with-lock (lock) + (with-lock-held (lock) (condition-notify condition-variable))) (error (e) (setf (box:unbox results) e) - (with-lock (lock) + (with-lock-held (lock) (condition-notify condition-variable)))))) (defun push-function-and-wait-results (fn &key @@ -265,7 +265,7 @@ (lock (lock event)) (condition-variable (condition-variable event))) (funcall push-event-fn event) - (with-lock (lock) + (with-lock-held (lock) (loop while (eq (box:unbox (results event)) :nothing) do @@ -344,7 +344,7 @@ (condition-variable condition-variable)) object (setf (command-window:echo-character specials:*command-window*) :completed) - (with-lock (lock) + (with-lock-held (lock) (condition-notify condition-variable)))) (defclass notify-user-event (program-event) diff --git a/src/tests/program-events-tests.lisp b/src/tests/program-events-tests.lisp index 7d7c150..9aef09f 100644 --- a/src/tests/program-events-tests.lisp +++ b/src/tests/program-events-tests.lisp @@ -40,7 +40,7 @@ (with-accessors ((lock program-events::lock) (condition-variable program-events::condition-variable)) event (push-event event) - (with-lock (lock) + (with-lock-held (lock) (format t "wait!~%") (condition-wait condition-variable lock) (format t "input was ~a~%" (dunbox (payload event))))))) diff --git a/src/ui-goodies.lisp b/src/ui-goodies.lisp index 43a6e14..f436806 100644 --- a/src/ui-goodies.lisp +++ b/src/ui-goodies.lisp @@ -241,7 +241,7 @@ (with-accessors ((lock lock) (condition-variable condition-variable)) event (push-event event) - (with-lock (lock) + (with-lock-held (lock) (loop while (not (eq (command-window:echo-character *command-window*) :completed))