diff options
Diffstat (limited to 'lib/std')
| -rw-r--r-- | lib/std/Thread.zig | 1 | ||||
| -rw-r--r-- | lib/std/Thread/Pool.zig | 21 |
2 files changed, 22 insertions, 0 deletions
diff --git a/lib/std/Thread.zig b/lib/std/Thread.zig index 25261053ee..3c2c9251d0 100644 --- a/lib/std/Thread.zig +++ b/lib/std/Thread.zig @@ -1465,6 +1465,7 @@ test { _ = Semaphore; _ = Condition; _ = RwLock; + _ = Pool; } fn testIncrementNotify(value: *usize, event: *ResetEvent) void { diff --git a/lib/std/Thread/Pool.zig b/lib/std/Thread/Pool.zig index 1a67b9735f..86bac7ce46 100644 --- a/lib/std/Thread/Pool.zig +++ b/lib/std/Thread/Pool.zig @@ -254,6 +254,27 @@ pub fn spawn(pool: *Pool, comptime func: anytype, args: anytype) !void { pool.cond.signal(); } +test spawn { + const TestFn = struct { + fn checkRun(completed: *bool) void { + completed.* = true; + } + }; + + var completed: bool = false; + + { + var pool: Pool = undefined; + try pool.init(.{ + .allocator = std.testing.allocator, + }); + defer pool.deinit(); + try pool.spawn(TestFn.checkRun, .{&completed}); + } + + try std.testing.expectEqual(true, completed); +} + fn worker(pool: *Pool) void { pool.mutex.lock(); defer pool.mutex.unlock(); |
