Commit 584b062a30

Jim Price <shadeops@gmail.com>
2023-07-26 15:19:52
Fix counting in SingleThreadedRwLock's tryLockShared (#16560)
Additionally we add RwLock to Thread.zig's list of tests
1 parent a8a2f2b
Changed files (2)
lib
lib/std/Thread/RwLock.zig
@@ -95,7 +95,11 @@ pub const SingleThreadedRwLock = struct {
                 rwl.shared_count = 1;
                 return true;
             },
-            .locked_exclusive, .locked_shared => return false,
+            .locked_shared => {
+                rwl.shared_count += 1;
+                return true;
+            },
+            .locked_exclusive => return false,
         }
     }
 
lib/std/Thread.zig
@@ -1438,6 +1438,7 @@ test {
     _ = Mutex;
     _ = Semaphore;
     _ = Condition;
+    _ = RwLock;
 }
 
 fn testIncrementNotify(value: *usize, event: *ResetEvent) void {