add atomic to keep track of processed blocks for eof sync
This commit is contained in:
parent
00637026ea
commit
f8847be2fb
1 changed files with 6 additions and 1 deletions
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue