4 ms·
You still need async (or an event loop model) because otherwise your threads will block waiting for the io_uring result when they could be put to better use (na
by ComputerGuru 3y ago
You still need async (or an event loop model) because otherwise your threads will block waiting for the io_uring result when they could be put to better use (namely submitting new io_uring jobs or conveying the results of completed ones).
Note that the io_uring approach isn't too different (just more universalized) than how Windows has always implemented async operations (with overlapped and io completion ports). Code written for that environment originally just used the event loop model but it's easier/better ergonomics to wrap it in async and use that instead (e.g. how C#'s async/await works) because you can avoid callback hell, state passing, etc. and just write code "linearly" with cooperative yield points invisibly stashing and retrieving the "stack" for you.
- memefrog 3y agoWhat? The total opposite is true! 'async/await' is callback hell. It's the barest syntactic sugar over it, but it's definitely callback hell. You write code sequentially if you use threads (whether they're userspace M:N or N:1 threads, or 1:1 kernel threads).
- ComputerGuru 3y agoSorry, not callback hell (that's what JS had before async/await) but certainly not code that linearly handles a connection from start to end, either. (Threaded code is certainly "linear" but I meant from the perspective of walking through the lifetime of a connection, one connection at a time linearly.)