diff --git a/src/input.zig b/src/input.zig index 3014ebb..5b72e9f 100644 --- a/src/input.zig +++ b/src/input.zig @@ -58,9 +58,12 @@ fn read_chrom(f: std.fs.File, source_buff: [][]util.Block, target_buff: [][]util } } -pub fn main_loop(f: std.fs.File, buffs: util.Buffers, thread_mgr: threads.ThreadManager) !void { +pub fn main_loop(f: std.fs.File, buffs: util.Buffers, thread_mgr: *threads.ThreadManager) !void { + thread_mgr.unblock(); try read_lum(f, buffs.Y, buffs.Y_quant, buffs.input_buff, thread_mgr.queue_wrp.queue); try read_chrom(f, buffs.U, buffs.U_quant, buffs.input_buff[0 .. buffs.input_buff.len / 2], thread_mgr.queue_wrp.queue); try read_chrom(f, buffs.V, buffs.V_quant, buffs.input_buff[0 .. buffs.input_buff.len / 2], thread_mgr.queue_wrp.queue); while (thread_mgr.signals.processed.load(.Acquire) != buffs.num_blocks) : (std.time.sleep(1)) {} + thread_mgr.eof(); + thread_mgr.quit(); } diff --git a/src/main.zig b/src/main.zig index 1555867..dfc143c 100644 --- a/src/main.zig +++ b/src/main.zig @@ -65,5 +65,5 @@ pub fn main() !void { defer thread_manager.deinit(); var f = std.io.getStdIn(); - try input.main_loop(f, buffs, thread_manager); + try input.main_loop(f, buffs, &thread_manager); }