authorgravatar for stephen@hexops.comStephen Gutekanst <stephen@hexops.com> 2022-04-10 20:53:56-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2022-04-11 03:02:41-04:00
logd2681d2537b630359657e117ed77cf12a15bb7df
tree711e820ac9f3003f0bca0f61702f0fa1955e5b06
parent971ef7b9c2d67ee849e252e75b79ee1e1ef3da6f

std.event.WaitGroup: fix compilation (acquire->lock, release->unlock)

In 008b0ec5e58fc7e31f3b989868a7d1ea4df3f41d the `std.Thread.Mutex` API was changed from `acquire` and `release` to `lock` and `unlock`. `std.event.Lock` still uses `acquire` and `release`. `std.event.WaitGroup` is using `std.Thread.Mutex` and was not updated to use `lock` and `unlock`, and so compilation failed prior to this commit. Signed-off-by: Stephen Gutekanst <stephen@hexops.com>

1 files changed, 7 insertions(+), 7 deletions(-)

lib/std/event/wait_group.zig+7-7
......@@ -35,8 +35,8 @@ pub fn WaitGroupGeneric(comptime counter_size: u16) type {
3535
3636 const Self = @This();
3737 pub fn begin(self: *Self, count: CounterType) error{Overflow}!void {
38 const held = self.mutex.acquire();
39 defer held.release();
38 self.mutex.lock();
39 defer self.mutex.unlock();
4040
4141 const new_counter = try std.math.add(CounterType, self.counter, count);
4242 if (new_counter > self.max_counter) return error.Overflow;
......@@ -45,8 +45,8 @@ pub fn WaitGroupGeneric(comptime counter_size: u16) type {
4545
4646 pub fn finish(self: *Self, count: CounterType) void {
4747 var waiters = blk: {
48 const held = self.mutex.acquire();
49 defer held.release();
48 self.mutex.lock();
49 defer self.mutex.unlock();
5050 self.counter = std.math.sub(CounterType, self.counter, count) catch unreachable;
5151 if (self.counter == 0) {
5252 const temp = self.waiters;
......@@ -65,10 +65,10 @@ pub fn WaitGroupGeneric(comptime counter_size: u16) type {
6565 }
6666
6767 pub fn wait(self: *Self) void {
68 const held = self.mutex.acquire();
68 self.mutex.lock();
6969
7070 if (self.counter == 0) {
71 held.release();
71 self.mutex.unlock();
7272 return;
7373 }
7474
......@@ -83,7 +83,7 @@ pub fn WaitGroupGeneric(comptime counter_size: u16) type {
8383 self_waiter.next = null;
8484 }
8585 suspend {
86 held.release();
86 self.mutex.unlock();
8787 }
8888 }
8989 };