refactor: migrate to Zig 0.16.0-dev.2676 PriorityQueue API#1
Conversation
GrapeBaBa
commented
Feb 28, 2026
- Rename PriorityQueue methods: init→initContext, add→push, remove→pop, removeIndex→popIndex, deinit now takes allocator
- Add self.* = undefined in EventClock.deinit for memory poisoning
- Split triple compound condition in SlotClock AdvanceIterator
- Update workaround comments for macOS GCD bug #31307
There was a problem hiding this comment.
Pull request overview
Migrates the clock/event loop implementation to Zig 0.16.0-dev.2676 by updating std.PriorityQueue usage and related cleanup, while also improving some internal safety/clarity in deinit paths and iterator logic.
Changes:
- Updated
std.PriorityQueueusage inEventClockto the new API (initContext,push,pop,popIndex,deinit(allocator)). - Added memory poisoning in
EventClock.deinit(self.* = undefined) after releasing resources. - Refactored
SlotClock.AdvanceIteratorepoch-boundary condition into clearer nested optionals and refreshed macOS GCD workaround comments/tests.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
src/SlotClock.zig |
Refactors epoch-boundary detection in AdvanceIterator to avoid triple-compound optional checks. |
src/EventClock.zig |
Migrates waiter priority queue calls to Zig 0.16 API; adjusts deinit, comments, and a real-time test name. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
src/EventClock.zig
Outdated
| ) catch { | ||
| // Transient error — re-check stopped flag. | ||
| continue; |
There was a problem hiding this comment.
std.Io.sleep errors are being swallowed silently here. If sleep starts failing persistently (e.g., due to an I/O subsystem issue), the loop will tight-spin and provide no diagnostic signal. Consider capturing the error (catch |err|) and either logging it (ideally rate-limited) and/or stopping the loop on non-transient errors to avoid high CPU usage and invisible failures.
| ) catch { | |
| // Transient error — re-check stopped flag. | |
| continue; | |
| ) catch |err| { | |
| std.log.err("EventClock: std.Io.sleep failed: {s}; stopping auto loop to avoid spin", .{@errorName(err)}); | |
| self.stop(); | |
| break; |
90a18c2 to
83585d4
Compare
- Rename PriorityQueue methods: init→initContext, add→push, remove→pop, removeIndex→popIndex, deinit now takes allocator - Add self.* = undefined in EventClock.deinit for memory poisoning - Split triple compound condition in SlotClock AdvanceIterator - Update workaround comments for macOS GCD bug #31307
83585d4 to
915ca21
Compare