3 ms·
This looks like Go: The code is synchronous, but I/O uses polling under the hood, so that the programmer gets the best of both worlds. When a Goroutine would b
by fooyc 6y ago
This looks like Go: The code is synchronous, but I/O uses polling under the hood, so that the programmer gets the best of both worlds.
When a Goroutine would block, it's parked by the scheduler, thus allowing an other Goroutine to execute. And it's not only about I/O: This works for any syscall, or even for CPU-bound computations.
There is no clever trick from the compiler to allow this: There is just a hook to the scheduler in low-level I/O code as well as before and after syscalls.