3 ms·
Thanks for confirming. So what does Zig actually do to execute async functions? Green threads in the background? An event loop? Is there documentation on the im
by kbd 4y ago
Thanks for confirming. So what does Zig actually do to execute async functions? Green threads in the background? An event loop? Is there documentation on the implementation?
- kristoff_it 4y agoWhen you set `const io_mode = .evented;` the stdlib observes that value and - flips I/O functions to evented mode, both by setting the correct flags when creating, say, a socket, and also by having `suspend` and similar keywords in the winning branch of some comptime conditional statements, causing the functions in question to become async also in the language. - instead of directly calling into main at program start, it starts an event loop and schedules main on it This is all userland stuff based on a convention, none of this is ingrained in the programming language itself and it could very well be that in the future things will have to be done in a more explicit way. Async functions are single frames (as opposed to being green threads).