chore: improve APU accuracy + scheduler refactoring

This commit is contained in:
2022-05-20 16:01:12 -03:00
parent e7777737b3
commit af2ad6c924
5 changed files with 39 additions and 43 deletions

View File

@@ -16,7 +16,7 @@ pub const Scheduler = struct {
pub fn init(alloc: Allocator) Self {
var sched = Self{ .tick = 0, .queue = PriorityQueue(Event, void, lessThan).init(alloc, {}) };
sched.push(.HeatDeath, std.math.maxInt(u64));
sched.queue.add(.{ .kind = .HeatDeath, .tick = std.math.maxInt(u64) }) catch unreachable;
return sched;
}
@@ -87,7 +87,7 @@ pub const Scheduler = struct {
}
pub fn push(self: *Self, kind: EventKind, end: u64) void {
self.queue.add(.{ .kind = kind, .tick = end }) catch unreachable;
self.queue.add(.{ .kind = kind, .tick = self.now() + end }) catch unreachable;
}
pub fn nextTimestamp(self: *Self) u64 {