Re:Goroutines, Nonblocking I/O, and Memory Usage
by steveklabnik on Friday January 06, 2017 @11:36AM
(#13337664)
Yeah we map the IOCP model to a readiness one, so it's totally platform independent. Wonder if you all could do the same.
* Async await
* The async dispatcher (event loop)
* Selectors module
Each builds on top of the layers below it. The selectors module is an abstraction for the various system `select()` mechanism such as epoll or kqueue. If you wish you can use it directly, and some people have done so successfully[1]. But you must be aware that on Windows it only supports `select()`.
The async dispatcher implements the proactor pattern and also has an implementation of IOCP. It implements the proactor pattern for other OS' via the selectors module. Futures are also implemented here, and indeed all the procedures return a future.
The final layer is the async await transformation. This allows you to write asynchronous code in a synchronous style and works similar to C#'s await. The transformation works by converting any async procedures into an iterator.
This is also single threaded and fully non-blocking and does give you a lot of control. In theory you should be able to work with any of these layers interchangeably (as long as you only care about non-Windows platforms).
1 - http://goran.krampe.se/2014/10/25/nim-socketserver/