Merge pull request #169 from blurrycat/fix/thread_anon_struct

Fix anonymous struct literal in log_thread spawn
This commit is contained in:
bobf 2025-03-07 21:00:18 +00:00 committed by GitHub
commit b8af924f8e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 6 additions and 2 deletions

View File

@ -62,7 +62,7 @@ pub fn start(self: *const App, routes_module: type, options: AppOptions) !void {
var log_thread = try std.Thread.spawn(
.{ .allocator = self.allocator },
jetzig.loggers.LogQueue.Reader.publish,
.{ &self.env.log_queue.reader, .{} },
.{ &self.env.log_queue.reader, jetzig.loggers.LogQueue.Reader.PublishOptions{} },
);
defer log_thread.join();

View File

@ -147,9 +147,13 @@ pub const Reader = struct {
stderr_file: std.fs.File,
queue: *LogQueue,
pub const PublishOptions = struct {
oneshot: bool = false,
};
/// Publish log events from the queue. Invoke from a dedicated thread. Sleeps when log queue
/// is empty, wakes up when a new event is published.
pub fn publish(self: *Reader, options: struct { oneshot: bool = false }) !void {
pub fn publish(self: *Reader, options: PublishOptions) !void {
std.debug.assert(self.queue.state == .ready);
const stdout_writer = self.stdout_file.writer();