authorgravatar for shadeops@gmail.comJim Price <shadeops@gmail.com> 2023-07-26 06:19:52-07:00
committergravatar for noreply@github.comGitHub <noreply@github.com> 2023-07-26 08:19:52-05:00
log584b062a302ca10ecab4488a473440db7173bb2a
treea41bb1345bafba3d06675d5cfa4c5a5474bfdef1
parenta8a2f2b58bd6f876258bb01b370a66c31d82f330
signaturebadge-question-mark Signed by PGP key 4AEE18F83AFDEB23

Fix counting in SingleThreadedRwLock's tryLockShared (#16560)

Additionally we add RwLock to Thread.zig's list of tests

2 files changed, 6 insertions(+), 1 deletions(-)

lib/std/Thread.zig+1
...@@ -1438,6 +1438,7 @@ test {...@@ -1438,6 +1438,7 @@ test {
1438 _ = Mutex;1438 _ = Mutex;
1439 _ = Semaphore;1439 _ = Semaphore;
1440 _ = Condition;1440 _ = Condition;
1441 _ = RwLock;
1441}1442}
14421443
1443fn testIncrementNotify(value: *usize, event: *ResetEvent) void {1444fn testIncrementNotify(value: *usize, event: *ResetEvent) void {
lib/std/Thread/RwLock.zig+5-1
...@@ -95,7 +95,11 @@ pub const SingleThreadedRwLock = struct {...@@ -95,7 +95,11 @@ pub const SingleThreadedRwLock = struct {
95 rwl.shared_count = 1;95 rwl.shared_count = 1;
96 return true;96 return true;
97 },97 },
98 .locked_exclusive, .locked_shared => return false,98 .locked_shared => {
99 rwl.shared_count += 1;
100 return true;
101 },
102 .locked_exclusive => return false,
99 }103 }
100 }104 }
101105