From c89aac85c440ea4cbccf1abdbd6acf84a33077e3 Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Mon, 9 Jul 2018 21:21:59 -0400 Subject: better workaround for guaranteeing memory in coroutine frame See #1194 --- std/atomic/queue_mpsc.zig | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'std/atomic/queue_mpsc.zig') diff --git a/std/atomic/queue_mpsc.zig b/std/atomic/queue_mpsc.zig index bc0a94258b..978e189453 100644 --- a/std/atomic/queue_mpsc.zig +++ b/std/atomic/queue_mpsc.zig @@ -60,6 +60,31 @@ pub fn QueueMpsc(comptime T: type) type { } return self.outbox.isEmpty(); } + + /// For debugging only. No API guarantees about what this does. + pub fn dump(self: *Self) void { + { + var it = self.outbox.root; + while (it) |node| { + std.debug.warn("0x{x} -> ", @ptrToInt(node)); + it = node.next; + } + } + const inbox_index = self.inbox_index; + const inboxes = []*std.atomic.Stack(T){ + &self.inboxes[self.inbox_index], + &self.inboxes[1 - self.inbox_index], + }; + for (inboxes) |inbox| { + var it = inbox.root; + while (it) |node| { + std.debug.warn("0x{x} -> ", @ptrToInt(node)); + it = node.next; + } + } + + std.debug.warn("null\n"); + } }; } -- cgit v1.2.3