From f8847be2fbc167542d08cb1d4bf77e3bede77a09 Mon Sep 17 00:00:00 2001 From: Muaz Ahmad Date: Mon, 27 Nov 2023 16:45:47 +0500 Subject: [PATCH] add atomic to keep track of processed blocks for eof sync --- src/threads.zig | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/threads.zig b/src/threads.zig index 3c80c16..b3490d1 100644 --- a/src/threads.zig +++ b/src/threads.zig @@ -1,17 +1,21 @@ const std = @import("std"); const util = @import("util.zig"); +const transform = @import("transform.zig"); const AtomicBool = std.atomic.Atomic(bool); +const AtomicU32 = std.atomic.Atomic(u32); const Signals = struct { quit: AtomicBool, + processed: AtomicU32, const Self = @This(); fn init() Self { return Self{ .quit = AtomicBool.init(false), + .processed = AtomicU32.init(0), }; } }; @@ -70,6 +74,7 @@ pub const ThreadManager = struct { fn quantize_loop(queue: *util.JobQueue, signals: *Signals) void { while (queue.HasJobs() or !signals.quit.load(std.builtin.AtomicOrder.Acquire)) : (std.time.sleep(1)) { const job = queue.pop() orelse continue; - std.debug.print("{any}\n", .{job.source.*}); + transform.quantize(job.source, job.target); + _ = @atomicRmw(u32, &signals.processed.value, .Add, 1, .SeqCst); } }