| ... | @@ -35,8 +35,8 @@ pub fn WaitGroupGeneric(comptime counter_size: u16) type { | ... | @@ -35,8 +35,8 @@ pub fn WaitGroupGeneric(comptime counter_size: u16) type { |
| 35 | | 35 | |
| 36 | const Self = @This(); | 36 | const Self = @This(); |
| 37 | pub fn begin(self: *Self, count: CounterType) error{Overflow}!void { | 37 | pub fn begin(self: *Self, count: CounterType) error{Overflow}!void { |
| 38 | const held = self.mutex.acquire(); | 38 | self.mutex.lock(); |
| 39 | defer held.release(); | 39 | defer self.mutex.unlock(); |
| 40 | | 40 | |
| 41 | const new_counter = try std.math.add(CounterType, self.counter, count); | 41 | const new_counter = try std.math.add(CounterType, self.counter, count); |
| 42 | if (new_counter > self.max_counter) return error.Overflow; | 42 | if (new_counter > self.max_counter) return error.Overflow; |
| ... | @@ -45,8 +45,8 @@ pub fn WaitGroupGeneric(comptime counter_size: u16) type { | ... | @@ -45,8 +45,8 @@ pub fn WaitGroupGeneric(comptime counter_size: u16) type { |
| 45 | | 45 | |
| 46 | pub fn finish(self: *Self, count: CounterType) void { | 46 | pub fn finish(self: *Self, count: CounterType) void { |
| 47 | var waiters = blk: { | 47 | var waiters = blk: { |
| 48 | const held = self.mutex.acquire(); | 48 | self.mutex.lock(); |
| 49 | defer held.release(); | 49 | defer self.mutex.unlock(); |
| 50 | self.counter = std.math.sub(CounterType, self.counter, count) catch unreachable; | 50 | self.counter = std.math.sub(CounterType, self.counter, count) catch unreachable; |
| 51 | if (self.counter == 0) { | 51 | if (self.counter == 0) { |
| 52 | const temp = self.waiters; | 52 | const temp = self.waiters; |
| ... | @@ -65,10 +65,10 @@ pub fn WaitGroupGeneric(comptime counter_size: u16) type { | ... | @@ -65,10 +65,10 @@ pub fn WaitGroupGeneric(comptime counter_size: u16) type { |
| 65 | } | 65 | } |
| 66 | | 66 | |
| 67 | pub fn wait(self: *Self) void { | 67 | pub fn wait(self: *Self) void { |
| 68 | const held = self.mutex.acquire(); | 68 | self.mutex.lock(); |
| 69 | | 69 | |
| 70 | if (self.counter == 0) { | 70 | if (self.counter == 0) { |
| 71 | held.release(); | 71 | self.mutex.unlock(); |
| 72 | return; | 72 | return; |
| 73 | } | 73 | } |
| 74 | | 74 | |
| ... | @@ -83,7 +83,7 @@ pub fn WaitGroupGeneric(comptime counter_size: u16) type { | ... | @@ -83,7 +83,7 @@ pub fn WaitGroupGeneric(comptime counter_size: u16) type { |
| 83 | self_waiter.next = null; | 83 | self_waiter.next = null; |
| 84 | } | 84 | } |
| 85 | suspend { | 85 | suspend { |
| 86 | held.release(); | 86 | self.mutex.unlock(); |
| 87 | } | 87 | } |
| 88 | } | 88 | } |
| 89 | }; | 89 | }; |