this repo has no description
13
fork

Configure Feed

Select the types of activity you want to include in your feed.

fix: Realtime timers break during computer suspend. Inverted condition in checkTimers.

authored by

Gliptic and committed by
Tim Culverhouse
53522b8b 0f46f499

+7 -7
+6 -6
src/vxfw/App.zig
··· 96 96 defer focus_handler.deinit(self.allocator); 97 97 98 98 // Timestamp of our next frame 99 - var next_frame = std.Io.Timestamp.now(self.io, .real); 99 + var next_frame = std.Io.Timestamp.now(self.io, .awake); 100 100 101 101 // Create our event context 102 102 var ctx: vxfw.EventContext = .{ ··· 111 111 defer ctx.cmds.deinit(self.allocator); 112 112 113 113 while (true) { 114 - const now = std.Io.Timestamp.now(self.io, .real); 114 + const now = std.Io.Timestamp.now(self.io, .awake); 115 115 const duration = now.durationTo(next_frame); 116 116 if (duration.nanoseconds <= 0) { 117 117 // Deadline exceeded. Schedule the next frame 118 118 next_frame = now.addDuration(tick); 119 119 } else { 120 120 // Sleep until the deadline 121 - try self.io.sleep(duration, .real); 121 + try self.io.sleep(duration, .awake); 122 122 next_frame = next_frame.addDuration(tick); 123 123 } 124 124 ··· 297 297 } 298 298 299 299 fn checkTimers(self: *App, ctx: *vxfw.EventContext) anyerror!void { 300 - const now: std.Io.Timestamp = .now(self.io, .real); 300 + const now: std.Io.Timestamp = .now(self.io, .awake); 301 301 302 302 // timers are always sorted descending 303 303 while (self.timers.pop()) |tick| { 304 304 const duration = now.durationTo(tick.deadline); 305 - if (duration.nanoseconds < 0) { 306 - // re-add the timer 305 + if (duration.nanoseconds > 0) { 306 + // re-add the timer as no more timers will trigger now 307 307 try self.timers.append(self.allocator, tick); 308 308 break; 309 309 }
+1 -1
src/vxfw/vxfw.zig
··· 62 62 } 63 63 64 64 pub fn in(io: std.Io, ms: u32, widget: Widget) Command { 65 - const now: std.Io.Timestamp = .now(io, .real); 65 + const now: std.Io.Timestamp = .now(io, .awake); 66 66 const deadline = now.addDuration(.fromMilliseconds(ms)); 67 67 return .{ 68 68 .tick = .{