diff options
| author | 2025-10-19 07:36:50 +0300 | |
|---|---|---|
| committer | 2025-10-19 07:36:50 +0300 | |
| commit | f519c709b387e350cdf3ffc71e31c9fbfbb502e5 (patch) | |
| tree | 8b86edfd8df76307a8a143bd1342beb080528b2a /src/rw-lock.lisp | |
| parent | Get rid of a couple warnings in main.lisp (diff) | |
| download | ukkoclot-f519c709b387e350cdf3ffc71e31c9fbfbb502e5.tar.gz ukkoclot-f519c709b387e350cdf3ffc71e31c9fbfbb502e5.tar.xz ukkoclot-f519c709b387e350cdf3ffc71e31c9fbfbb502e5.zip | |
Added checks against releasing an untaken lock
Diffstat (limited to 'src/rw-lock.lisp')
| -rw-r--r-- | src/rw-lock.lisp | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/src/rw-lock.lisp b/src/rw-lock.lisp index b32d3d0..bd2606c 100644 --- a/src/rw-lock.lisp +++ b/src/rw-lock.lisp | |||
| @@ -72,6 +72,7 @@ | |||
| 72 | (check-type rw-lock rw-lock) | 72 | (check-type rw-lock rw-lock) |
| 73 | (with-slots (lock unlocked readers has-writer) rw-lock | 73 | (with-slots (lock unlocked readers has-writer) rw-lock |
| 74 | (with-lock-held (lock) | 74 | (with-lock-held (lock) |
| 75 | (assert (> readers 0) nil "Trying to release a read lock that's not taken!") | ||
| 75 | (decf readers) | 76 | (decf readers) |
| 76 | (when (zerop readers) | 77 | (when (zerop readers) |
| 77 | (condition-broadcast unlocked)))) | 78 | (condition-broadcast unlocked)))) |
| @@ -117,6 +118,7 @@ | |||
| 117 | (check-type rw-lock rw-lock) | 118 | (check-type rw-lock rw-lock) |
| 118 | (with-slots (lock unlocked readers has-writer) rw-lock | 119 | (with-slots (lock unlocked readers has-writer) rw-lock |
| 119 | (with-lock-held (lock) | 120 | (with-lock-held (lock) |
| 121 | (assert has-writer nil "Trying to release a write lock that's not taken!") | ||
| 120 | (setf has-writer nil) | 122 | (setf has-writer nil) |
| 121 | (condition-broadcast unlocked))) | 123 | (condition-broadcast unlocked))) |
| 122 | rw-lock) | 124 | rw-lock) |