diff options
| author | Stephen Gutekanst <stephen@hexops.com> | 2022-04-10 20:53:56 -0700 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2022-04-11 03:02:41 -0400 |
| commit | d2681d2537b630359657e117ed77cf12a15bb7df (patch) | |
| tree | 711e820ac9f3003f0bca0f61702f0fa1955e5b06 /lib/std/event | |
| parent | 971ef7b9c2d67ee849e252e75b79ee1e1ef3da6f (diff) | |
| download | zig-d2681d2537b630359657e117ed77cf12a15bb7df.tar.gz zig-d2681d2537b630359657e117ed77cf12a15bb7df.zip | |
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 (limited to 'lib/std/event')
| -rw-r--r-- | lib/std/event/wait_group.zig | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/lib/std/event/wait_group.zig b/lib/std/event/wait_group.zig index d26986f384..4cc82cf98e 100644 --- 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(); } } }; |
