1
0
Fork 0

- replaced occurences of 'with-lock' with 'misc:with-lock-held'.

This commit is contained in:
cage 2024-02-11 15:08:16 +01:00
parent 5155749080
commit e4d9ab9fd0
7 changed files with 28 additions and 28 deletions

View File

@ -51,7 +51,7 @@
(find-db-stream-if (lambda (a) (string= (download-iri a) url)))) (find-db-stream-if (lambda (a) (string= (download-iri a) url))))
(defun ensure-just-one-stream-rendering () (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) (when-let ((current-rendering (find-db-stream-if (lambda (a)
(eq (stream-status a) (eq (stream-status a)
:rendering))))) :rendering)))))
@ -226,28 +226,28 @@
(defmethod abort-downloading ((object gemini-stream)) (defmethod abort-downloading ((object gemini-stream))
(with-accessors ((download-thread-lock download-thread-lock)) object (with-accessors ((download-thread-lock download-thread-lock)) object
(setf (stream-status object) :aborted) (setf (stream-status object) :aborted)
(with-lock (download-thread-lock) (with-lock-held (download-thread-lock)
(setf (download-thread-blocked object) t)))) (setf (download-thread-blocked object) t))))
(defmethod allow-downloading ((object gemini-stream)) (defmethod allow-downloading ((object gemini-stream))
(with-accessors ((download-thread-lock download-thread-lock)) object (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)))) (setf (download-thread-blocked object) nil))))
(defmethod downloading-allowed-p ((object gemini-stream)) (defmethod downloading-allowed-p ((object gemini-stream))
(with-accessors ((download-thread-lock download-thread-lock)) object (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))))) (not (download-thread-blocked-p object)))))
(defmethod (setf stream-status) (val (object gemini-stream)) (defmethod (setf stream-status) (val (object gemini-stream))
(with-accessors ((download-thread-lock download-thread-lock) (with-accessors ((download-thread-lock download-thread-lock)
(stream-status stream-status)) object (stream-status stream-status)) object
(with-lock (download-thread-lock) (with-lock-held (download-thread-lock)
(setf (slot-value object 'stream-status) val)))) (setf (slot-value object 'stream-status) val))))
(defmethod stream-status ((object gemini-stream)) (defmethod stream-status ((object gemini-stream))
(with-accessors ((download-thread-lock download-thread-lock)) object (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)))) (slot-value object 'stream-status))))
(defmethod downloading-start-thread ((object gemini-stream) (defmethod downloading-start-thread ((object gemini-stream)
@ -276,7 +276,7 @@
(with-accessors ((download-thread-lock download-thread-lock) (with-accessors ((download-thread-lock download-thread-lock)
(support-file support-file) (support-file support-file)
(parsed-lines parsed-lines)) object (parsed-lines parsed-lines)) object
(with-lock (download-thread-lock) (with-lock-held (download-thread-lock)
(gemini-parser:with-initialized-parser (gemini-parser:with-initialized-parser
(let ((event (make-gemini-download-event (fs:slurp-file support-file) (let ((event (make-gemini-download-event (fs:slurp-file support-file)
parsed-lines parsed-lines

View File

@ -50,7 +50,7 @@
(defgeneric make-request (method id &rest args)) (defgeneric make-request (method id &rest args))
(defmethod make-request ((method symbol) 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))) (apply #'make-request (string-downcase (symbol-name method)) id args)))
(define-condition rpc-error-response (conditions:text-error) (define-condition rpc-error-response (conditions:text-error)

View File

@ -24,11 +24,11 @@
(defgeneric streaming-url (object)) (defgeneric streaming-url (object))
(defmethod status ((object gemini-stream)) (defmethod status ((object gemini-stream))
(misc:with-lock ((status-lock object)) (misc:with-lock-held ((status-lock object))
(slot-value object 'status))) (slot-value object 'status)))
(defmethod (setf status) ((object gemini-stream) val) (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) (setf (slot-value object 'status) val)
val)) val))
@ -40,7 +40,7 @@
(defparameter *gemini-streams-db-lock* (make-lock "gemini-streams-db-lock")) (defparameter *gemini-streams-db-lock* (make-lock "gemini-streams-db-lock"))
(defun push-db-stream (stream-object) (defun push-db-stream (stream-object)
(misc:with-lock (*gemini-streams-db-lock*) (misc:with-lock-held (*gemini-streams-db-lock*)
(pushnew stream-object (pushnew stream-object
*gemini-streams-db* *gemini-streams-db*
:test (lambda (a b) :test (lambda (a b)
@ -49,7 +49,7 @@
*gemini-streams-db*)) *gemini-streams-db*))
(defun remove-db-stream (stream-object) (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* (setf *gemini-streams-db*
(remove stream-object *gemini-streams-db*)) (remove stream-object *gemini-streams-db*))
*gemini-streams-db*)) *gemini-streams-db*))
@ -58,7 +58,7 @@
(setf (status object) +stream-status-canceled+)) (setf (status object) +stream-status-canceled+))
(defun remove-all-db-stream () (defun remove-all-db-stream ()
(misc:with-lock (*gemini-streams-db-lock*) (misc:with-lock-held (*gemini-streams-db-lock*)
(map nil (map nil
(lambda (a) (abort-downloading a)) (lambda (a) (abort-downloading a))
*gemini-streams-db*) *gemini-streams-db*)
@ -66,7 +66,7 @@
*gemini-streams-db*)) *gemini-streams-db*))
(defun find-db-stream-if (predicate) (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*))) (find-if predicate *gemini-streams-db*)))
(defun find-db-stream-url (url) (defun find-db-stream-url (url)
@ -1519,11 +1519,11 @@ local file paths."
(defgeneric fit-toc-char-width (object new-width)) (defgeneric fit-toc-char-width (object new-width))
(defmethod interrupt-rendering-p ((object main-frame)) (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))) (slot-value object 'interrupt-rendering)))
(defun set-interrupt-rendering-state (main-frame value) (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))) (setf (slot-value main-frame 'interrupt-rendering) value)))
(defmethod interrupt-rendering ((object main-frame)) (defmethod interrupt-rendering ((object main-frame))

View File

@ -7,11 +7,11 @@
(defparameter *events-loop-thread* nil) (defparameter *events-loop-thread* nil)
(defun events-loop-running-p () (defun events-loop-running-p ()
(misc:with-lock (*events-loop-lock*) (misc:with-lock-held (*events-loop-lock*)
(not *stop-events-loop*))) (not *stop-events-loop*)))
(defun 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)) (setf *stop-events-loop* t))
#+debug-mode (misc:dbg "Stopping gui event thread") #+debug-mode (misc:dbg "Stopping gui event thread")
(ev:with-enqueued-process-and-unblock () (ev:with-enqueued-process-and-unblock ()
@ -19,7 +19,7 @@
#+debug-mode (misc:dbg "Stopped gui event thread")) #+debug-mode (misc:dbg "Stopped gui event thread"))
(defun start-events-loop () (defun start-events-loop ()
(misc:with-lock (*events-loop-lock*) (misc:with-lock-held (*events-loop-lock*)
(setf *stop-events-loop* nil)) (setf *stop-events-loop* nil))
(setf *events-loop-thread* (setf *events-loop-thread*
(make-thread (lambda () (make-thread (lambda ()

View File

@ -95,7 +95,7 @@
(defmacro wrapped-in-lock ((queue) &body body) (defmacro wrapped-in-lock ((queue) &body body)
(with-gensyms (lock) (with-gensyms (lock)
`(with-accessors ((,lock lock)) ,queue `(with-accessors ((,lock lock)) ,queue
(with-lock (,lock) (with-lock-held (,lock)
,@body)))) ,@body))))
(defclass events-queue (priority-queue) (defclass events-queue (priority-queue)
@ -152,7 +152,7 @@
object)) object))
(defun pop-event-block () (defun pop-event-block ()
(with-lock ((blocking-lock *events-queue*)) (with-lock-held ((blocking-lock *events-queue*))
(loop while (emptyp *events-queue*) (loop while (emptyp *events-queue*)
do do
(condition-wait (condition-variable *events-queue*) (condition-wait (condition-variable *events-queue*)
@ -160,7 +160,7 @@
(pop-element *events-queue*))) (pop-element *events-queue*)))
(defun push-event-unblock (value) (defun push-event-unblock (value)
(with-lock ((blocking-lock *events-queue*)) (with-lock-held ((blocking-lock *events-queue*))
(push-element *events-queue* value) (push-element *events-queue* value)
(condition-notify (condition-variable *events-queue*)))) (condition-notify (condition-variable *events-queue*))))
@ -249,11 +249,11 @@
(handler-case (handler-case
(progn (progn
(setf (box:unbox results) (funcall callback)) (setf (box:unbox results) (funcall callback))
(with-lock (lock) (with-lock-held (lock)
(condition-notify condition-variable))) (condition-notify condition-variable)))
(error (e) (error (e)
(setf (box:unbox results) e) (setf (box:unbox results) e)
(with-lock (lock) (with-lock-held (lock)
(condition-notify condition-variable)))))) (condition-notify condition-variable))))))
(defun push-function-and-wait-results (fn &key (defun push-function-and-wait-results (fn &key
@ -265,7 +265,7 @@
(lock (lock event)) (lock (lock event))
(condition-variable (condition-variable event))) (condition-variable (condition-variable event)))
(funcall push-event-fn event) (funcall push-event-fn event)
(with-lock (lock) (with-lock-held (lock)
(loop (loop
while (eq (box:unbox (results event)) :nothing) while (eq (box:unbox (results event)) :nothing)
do do
@ -344,7 +344,7 @@
(condition-variable condition-variable)) object (condition-variable condition-variable)) object
(setf (command-window:echo-character specials:*command-window*) (setf (command-window:echo-character specials:*command-window*)
:completed) :completed)
(with-lock (lock) (with-lock-held (lock)
(condition-notify condition-variable)))) (condition-notify condition-variable))))
(defclass notify-user-event (program-event) (defclass notify-user-event (program-event)

View File

@ -40,7 +40,7 @@
(with-accessors ((lock program-events::lock) (with-accessors ((lock program-events::lock)
(condition-variable program-events::condition-variable)) event (condition-variable program-events::condition-variable)) event
(push-event event) (push-event event)
(with-lock (lock) (with-lock-held (lock)
(format t "wait!~%") (format t "wait!~%")
(condition-wait condition-variable lock) (condition-wait condition-variable lock)
(format t "input was ~a~%" (dunbox (payload event))))))) (format t "input was ~a~%" (dunbox (payload event)))))))

View File

@ -241,7 +241,7 @@
(with-accessors ((lock lock) (with-accessors ((lock lock)
(condition-variable condition-variable)) event (condition-variable condition-variable)) event
(push-event event) (push-event event)
(with-lock (lock) (with-lock-held (lock)
(loop (loop
while (not (eq (command-window:echo-character *command-window*) while (not (eq (command-window:echo-character *command-window*)
:completed)) :completed))