formatting
This commit is contained in:
parent
2f7afe64f6
commit
3e20d948f8
1 changed files with 6 additions and 6 deletions
|
@ -10,7 +10,7 @@ const Signals = struct {
|
||||||
const Self = @This();
|
const Self = @This();
|
||||||
|
|
||||||
fn init() Self {
|
fn init() Self {
|
||||||
return Self {
|
return Self{
|
||||||
.quit = AtomicBool.init(false),
|
.quit = AtomicBool.init(false),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -25,7 +25,7 @@ const QueueWrap = struct {
|
||||||
fn init(alloc: std.mem.Allocator, job_pool: util.JobPool) !Self {
|
fn init(alloc: std.mem.Allocator, job_pool: util.JobPool) !Self {
|
||||||
var q = try alloc.create(util.JobQueue);
|
var q = try alloc.create(util.JobQueue);
|
||||||
q.* = util.JobQueue.init(job_pool);
|
q.* = util.JobQueue.init(job_pool);
|
||||||
return Self {
|
return Self{
|
||||||
.queue = q,
|
.queue = q,
|
||||||
.job_pool = job_pool,
|
.job_pool = job_pool,
|
||||||
};
|
};
|
||||||
|
@ -45,7 +45,7 @@ pub const ThreadManager = struct {
|
||||||
var arena = std.heap.ArenaAllocator.init(alloc);
|
var arena = std.heap.ArenaAllocator.init(alloc);
|
||||||
var arena_alloc = arena.allocator();
|
var arena_alloc = arena.allocator();
|
||||||
var job_pool = util.JobPool.init(alloc);
|
var job_pool = util.JobPool.init(alloc);
|
||||||
var thread_mgr = Self {
|
var thread_mgr = Self{
|
||||||
.threads = std.ArrayList(std.Thread).init(arena_alloc),
|
.threads = std.ArrayList(std.Thread).init(arena_alloc),
|
||||||
.arena = arena,
|
.arena = arena,
|
||||||
.queue_wrp = try QueueWrap.init(arena_alloc, job_pool),
|
.queue_wrp = try QueueWrap.init(arena_alloc, job_pool),
|
||||||
|
@ -55,9 +55,9 @@ pub const ThreadManager = struct {
|
||||||
thread_mgr.signals.* = Signals.init();
|
thread_mgr.signals.* = Signals.init();
|
||||||
|
|
||||||
for (0..n_quant_jobs) |_| {
|
for (0..n_quant_jobs) |_| {
|
||||||
try thread_mgr.threads.append(try std.Thread.spawn(.{}, quantize_loop, .{thread_mgr.queue_wrp.queue, thread_mgr.signals}));
|
try thread_mgr.threads.append(try std.Thread.spawn(.{}, quantize_loop, .{ thread_mgr.queue_wrp.queue, thread_mgr.signals }));
|
||||||
}
|
}
|
||||||
|
|
||||||
return thread_mgr;
|
return thread_mgr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -70,6 +70,6 @@ pub const ThreadManager = struct {
|
||||||
fn quantize_loop(queue: *util.JobQueue, signals: *Signals) void {
|
fn quantize_loop(queue: *util.JobQueue, signals: *Signals) void {
|
||||||
while (queue.HasJobs() or !signals.quit.load(std.builtin.AtomicOrder.Acquire)) : (std.time.sleep(1)) {
|
while (queue.HasJobs() or !signals.quit.load(std.builtin.AtomicOrder.Acquire)) : (std.time.sleep(1)) {
|
||||||
const job = queue.pop() orelse continue;
|
const job = queue.pop() orelse continue;
|
||||||
std.debug.print("{any}\n", .{job});
|
std.debug.print("{any}\n", .{job.source.*});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue