#Zig Interface and std.atomic.Queue
1 messages · Page 1 of 1 (latest)
im confused how do I craft it myself?
That's why i suggested to look at how it's done in zig std source code
allocator interface: https://github.com/ziglang/zig/blob/master/lib/std/mem/Allocator.zig
Reader interface: https://github.com/ziglang/zig/blob/master/lib/std/io/reader.zig
Writer interface: https://github.com/ziglang/zig/blob/master/lib/std/io/writer.zig
im afriad these just confuse me more, what does crafting entail? How does vtables relate to this all?
Those are all the details that other languages hide from you. This might help you understand it better: https://youtu.be/AHc4x1uXBQE
From Zig SHOWTIME #17
Subscribe to the Zig SHOWTIME Newsletter!
https://zig.show
0:00 Title
0:30 Talk
31:56 Interview
ahhh thank you will take a look
btw also for the queue how do I add something to queue?
Seems like a pretty simple interface: https://github.com/ziglang/zig/blob/master/lib/std/atomic/queue.zig#L31
Just make sure to store the object somewhere, queue will just manage the access to the item, but it won't take care of releasing the resources as mentioned in the documentation comment
im confused by the node type, How do I create a Node type to be put in the queue
it is bit confusing, can't explain why it was designed like that. The Node type comes from here:
https://github.com/ziglang/zig/blob/master/lib/std/linked_list.zig#L165
Always good idea to look for inline unit tests for usage examples https://github.com/ziglang/zig/blob/master/lib/std/atomic/queue.zig#L295
This isn't regular queue, it's a synchronization mechanism. The first link is to regular queue