commit d2681d2537b630359657e117ed77cf12a15bb7df (tree)
parent 971ef7b9c2d67ee849e252e75b79ee1e1ef3da6f
Author: Stephen Gutekanst <stephen@hexops.com>
Date: Sun, 10 Apr 2022 20:53:56 -0700
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>
Diffstat:
1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/lib/std/event/wait_group.zig b/lib/std/event/wait_group.zig
@@ -35,8 +35,8 @@ pub fn WaitGroupGeneric(comptime counter_size: u16) type {
const Self = @This();
pub fn begin(self: *Self, count: CounterType) error{Overflow}!void {
- const held = self.mutex.acquire();
- defer held.release();
+ self.mutex.lock();
+ defer self.mutex.unlock();
const new_counter = try std.math.add(CounterType, self.counter, count);
if (new_counter > self.max_counter) return error.Overflow;
@@ -45,8 +45,8 @@ pub fn WaitGroupGeneric(comptime counter_size: u16) type {
pub fn finish(self: *Self, count: CounterType) void {
var waiters = blk: {
- const held = self.mutex.acquire();
- defer held.release();
+ self.mutex.lock();
+ defer self.mutex.unlock();
self.counter = std.math.sub(CounterType, self.counter, count) catch unreachable;
if (self.counter == 0) {
const temp = self.waiters;
@@ -65,10 +65,10 @@ pub fn WaitGroupGeneric(comptime counter_size: u16) type {
}
pub fn wait(self: *Self) void {
- const held = self.mutex.acquire();
+ self.mutex.lock();
if (self.counter == 0) {
- held.release();
+ self.mutex.unlock();
return;
}
@@ -83,7 +83,7 @@ pub fn WaitGroupGeneric(comptime counter_size: u16) type {
self_waiter.next = null;
}
suspend {
- held.release();
+ self.mutex.unlock();
}
}
};