zig

fork of https://codeberg.org/ziglang/zig
Log | Files | Refs | README | LICENSE

commit 584b062a302ca10ecab4488a473440db7173bb2a (tree)
parent a8a2f2b58bd6f876258bb01b370a66c31d82f330
Author: Jim Price <shadeops@gmail.com>
Date:   Wed, 26 Jul 2023 06:19:52 -0700

Fix counting in SingleThreadedRwLock's tryLockShared (#16560)

Additionally we add RwLock to Thread.zig's list of tests
Diffstat:
Mlib/std/Thread.zig | 1+
Mlib/std/Thread/RwLock.zig | 6+++++-
2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/lib/std/Thread.zig b/lib/std/Thread.zig @@ -1438,6 +1438,7 @@ test { _ = Mutex; _ = Semaphore; _ = Condition; + _ = RwLock; } fn testIncrementNotify(value: *usize, event: *ResetEvent) void { diff --git a/lib/std/Thread/RwLock.zig b/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, } }