basic threading handler boiler
This commit is contained in:
parent
491f6a98b7
commit
6a6da59a79
2 changed files with 27 additions and 2 deletions
|
@ -1,6 +1,7 @@
|
|||
const std = @import("std");
|
||||
|
||||
const util = @import("util.zig");
|
||||
const threads = @import("threads.zig");
|
||||
|
||||
const InitError = error {
|
||||
NotEnoughArgs,
|
||||
|
@ -58,6 +59,7 @@ pub fn main() !void {
|
|||
|
||||
var buffs = try util.Buffers.init(std.heap.page_allocator, opts.width, opts.height, 1000);
|
||||
defer buffs.deinit();
|
||||
|
||||
std.debug.print("{any}\n", .{opts});
|
||||
|
||||
var thread_manager = try threads.ThreadManager.init(std.heap.page_allocator, opts.n_quant_jobs);
|
||||
defer thread_manager.deinit();
|
||||
}
|
||||
|
|
23
src/threads.zig
Normal file
23
src/threads.zig
Normal file
|
@ -0,0 +1,23 @@
|
|||
const std = @import("std");
|
||||
|
||||
pub const ThreadManager = struct {
|
||||
threads: std.ArrayList(std.Thread),
|
||||
arena: std.heap.ArenaAllocator,
|
||||
|
||||
const Self = @This();
|
||||
|
||||
pub fn init(alloc: std.mem.Allocator, n_quant_jobs: usize) !Self {
|
||||
_ = n_quant_jobs;
|
||||
var arena = std.heap.ArenaAllocator.init(alloc);
|
||||
var thread_mgr = Self {
|
||||
.threads = std.ArrayList(std.Thread).init(arena.allocator()),
|
||||
.arena = arena,
|
||||
};
|
||||
return thread_mgr;
|
||||
}
|
||||
|
||||
pub fn deinit(self: *Self) void {
|
||||
self.threads.deinit();
|
||||
self.arena.deinit();
|
||||
}
|
||||
};
|
Loading…
Reference in a new issue