Commit d2681d2537
Changed files (1)
lib
std
event
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();
}
}
};