mirror of
https://gitlab.com/embeddable-common-lisp/ecl.git
synced 2026-01-15 13:52:16 -08:00
Optimizations in with-lock: save reference to current process and use some fixnum comparisons.
This commit is contained in:
parent
312110ceca
commit
0ca6dbccbe
1 changed files with 9 additions and 5 deletions
|
|
@ -116,16 +116,20 @@ by ALLOW-WITH-INTERRUPTS."
|
|||
;; the get-lock statement, to ensure that the unlocking is done with
|
||||
;; interrupts disabled.
|
||||
#+threads
|
||||
(ext:with-unique-names (lock owner count)
|
||||
(ext:with-unique-names (lock owner count process)
|
||||
`(let* ((,lock ,lock-form)
|
||||
(,owner (mp:lock-owner ,lock))
|
||||
(,count (mp:lock-count ,lock)))
|
||||
(declare (type fixnum ,count))
|
||||
(without-interrupts
|
||||
(unwind-protect
|
||||
(with-restored-interrupts
|
||||
(mp::get-lock ,lock)
|
||||
(locally ,@body))
|
||||
(when (and (eq mp:*current-process* (mp:lock-owner ,lock))
|
||||
(or (not (eq ,owner mp:*current-process*))
|
||||
(> (mp:lock-count ,lock) ,count)))
|
||||
(mp::giveup-lock ,lock)))))))
|
||||
(let ((,process mp:*current-process*))
|
||||
(declare (optimize (speed 3) (safety 0) (debug 0)))
|
||||
(when (and (eq ,process (mp:lock-owner ,lock))
|
||||
(or (not (eq ,owner ,process))
|
||||
(> (the fixnum (mp:lock-count ,lock))
|
||||
(the fixnum ,count))))
|
||||
(mp::giveup-lock ,lock))))))))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue