Commit d2681d2537

Stephen Gutekanst <stephen@hexops.com>
2022-04-11 05:53:56
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 parent 971ef7b
Changed files (1)
lib
std
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();
             }
         }
     };