Skip to content

Conversation

Hanaasagi
Copy link

Rename head and tail pointer operations in the MPSC queue to align with standard queue semantics. Producers now push to the tail, and the consumer pops from the head, ensuring correct behavior and improving code clarity.

This change also aligns the implementation with the one in queue.zig, maintaining consistency across the project.

libxev/src/queue.zig

Lines 18 to 35 in b8d1d93

/// Head is the front of the queue and tail is the back of the queue.
head: ?*T = null,
tail: ?*T = null,
/// Enqueue a new element to the back of the queue.
pub fn push(self: *Self, v: *T) void {
assert(v.next == null);
if (self.tail) |tail| {
// If we have elements in the queue, then we add a new tail.
tail.next = v;
self.tail = v;
} else {
// No elements in the queue we setup the initial state.
self.head = v;
self.tail = v;
}
}
.

Rename head and tail pointer operations in the MPSC queue to align with standard queue semantics.
Producers now push to the tail, and the consumer pops from the head, ensuring correct behavior and improving code clarity.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant