From a6ba5fa8dffc45ec3ab37bc29235022b90841264 Mon Sep 17 00:00:00 2001 From: Jari Vetoniemi Date: Tue, 10 Sep 2024 11:19:39 +0900 Subject: [PATCH] TimerQueue: make stack size configurable and increase default stack size The stack size has to be larger if aio debug prints are enabled. --- src/minilib/TimerQueue.zig | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/minilib/TimerQueue.zig b/src/minilib/TimerQueue.zig index 946c57d..4d19f67 100644 --- a/src/minilib/TimerQueue.zig +++ b/src/minilib/TimerQueue.zig @@ -13,6 +13,8 @@ pub const Options = struct { /// Force the use of foreign backend even if the target platform is linux /// Mostly useful for testing force_foreign_backend: bool = build_options.force_foreign_timer_queue, + /// Stack size of a timer thread (includes expiration callbacks) + stack_size: usize = 1024 * 16, }; comptime { @@ -110,7 +112,7 @@ fn Queue(comptime name: []const u8, Impl: type) type { fn start(self: *@This()) !void { @setCold(true); if (self.thread) |_| unreachable; - self.thread = try std.Thread.spawn(.{ .allocator = self.queue.allocator, .stack_size = 1024 * 8 }, threadMain, .{self}); + self.thread = try std.Thread.spawn(.{ .allocator = self.queue.allocator, .stack_size = options.stack_size }, threadMain, .{self}); self.thread.?.setName(name) catch {}; } @@ -454,7 +456,7 @@ const LinuxTimerQueue = struct { fn start(self: *@This()) !void { @setCold(true); if (self.thread) |_| unreachable; - self.thread = try std.Thread.spawn(.{ .allocator = self.allocator, .stack_size = 1024 * 8 }, threadMain, .{self}); + self.thread = try std.Thread.spawn(.{ .allocator = self.allocator, .stack_size = options.stack_size }, threadMain, .{self}); self.thread.?.setName("TimerQueue Thread") catch {}; }