refactors, boiler for looping read
This commit is contained in:
parent
18a998e737
commit
2f7afe64f6
3 changed files with 21 additions and 7 deletions
10
src/input.zig
Normal file
10
src/input.zig
Normal file
|
@ -0,0 +1,10 @@
|
|||
const std = @import("std");
|
||||
|
||||
const util = @import("util.zig");
|
||||
const threads = @import("threads.zig");
|
||||
|
||||
pub fn main_loop(f: std.fs.File, buffs: util.Buffers, thread_mgr: threads.ThreadManager) !void {
|
||||
_ = thread_mgr;
|
||||
_ = buffs;
|
||||
_ = f;
|
||||
}
|
|
@ -2,8 +2,9 @@ const std = @import("std");
|
|||
|
||||
const util = @import("util.zig");
|
||||
const threads = @import("threads.zig");
|
||||
const input = @import("input.zig");
|
||||
|
||||
const InitError = error {
|
||||
const InitError = error{
|
||||
NotEnoughArgs,
|
||||
InvalidDimension,
|
||||
InvalidQuality,
|
||||
|
@ -46,7 +47,7 @@ fn get_opts() !util.Options {
|
|||
defer args.deinit();
|
||||
_ = args.next();
|
||||
|
||||
return util.Options {
|
||||
return util.Options{
|
||||
.width = try get_dim(try next_arg(&args)),
|
||||
.height = try get_dim(try next_arg(&args)),
|
||||
.quality = try get_qual(try next_arg(&args)),
|
||||
|
@ -62,4 +63,7 @@ pub fn main() !void {
|
|||
|
||||
var thread_manager = try threads.ThreadManager.init(std.heap.page_allocator, opts.n_quant_jobs);
|
||||
defer thread_manager.deinit();
|
||||
|
||||
var f = std.io.getStdIn();
|
||||
try input.main_loop(f, buffs, thread_manager);
|
||||
}
|
||||
|
|
|
@ -26,7 +26,7 @@ pub const JobQueue = struct {
|
|||
const Node = Self.Node;
|
||||
|
||||
pub fn init(pool: JobPool) Self {
|
||||
return Self {
|
||||
return Self{
|
||||
.mutex = std.Thread.Mutex{},
|
||||
.queue = List{},
|
||||
.job_pool = pool,
|
||||
|
@ -79,7 +79,7 @@ pub const Buffers = struct {
|
|||
var alloc = arena.allocator();
|
||||
const block_w = w / 16;
|
||||
const block_h = h / 16;
|
||||
var buffs = Self {
|
||||
var buffs = Self{
|
||||
.arena = arena,
|
||||
|
||||
.Y = try alloc.alloc([][4]Block, block_h),
|
||||
|
|
Loading…
Reference in a new issue