On 19 Mar 2015 at 19:58, Mathias Gaunard wrote:
Hi, this is my first time actually looking at the documentation of the library.
I think it would be interesting to develop a couple more things in the design or FAQ sections.
Suggested topics are welcome.
Why use a specific asynchronous model with its own when_all etc.? There is a standard way of defining asynchronous tasks, which is getting extended by compiler support using await/yield_value, so why not do something using that?
It's not too obvious from first glance, but an async_io_op is a
struct with a shared_future inside it which is publicly accessible
called 'h'. So it uses the standard STL11 asynchronous model, just
slightly hidden. The when_all etc is purely due to legacy reasons.
Indeed the reason I couldn't use shared_future directly is purely
legacy, back in the day I had to use shared_ptr
What about the relationship with ASIO? ASIO has its own event-driven main-loop system for asynchronous tasks, can AFIO use that and can ASIO use AFIO's future method for other types of I/O too?
AFIO uses ASIO's event loop. It doesn't use the async_result idiom of ASIO because for file i/o you want strong graph ordering, and that's a pain to do with async_result. A more functional idiom, for which I chose future-promise, makes strong ordering much easier to program. Once I get Fibers/resumable function support in there next release, writing strongly graph ordered filing system algorithms ought to become optimally easy, and then I can get down to writing race free tree visitors etc which right now are very messy to write and debug. The AFIO-ASIO integration isn't deep right now, though of course ASIO's async_result can work with any arbitrary sync object, and that includes an async_io_op. Writing code (mostly completion lambdas) which arbitrates between the two is straightforward, if verbose and tedious. What is needed is zero copy kernel side support, and AFIO's design intentionally allows that (i.e. async write this gather list from this file to this socket all in the kernel using DMA). I'll be honest it's not high on my priority list given no one is using AFIO anyway, but potential deep AFIO-ASIO integration is very high on the radar. I will say though I'll need changes to ASIO to make that work, so it's not a trivial feature add. Niall -- ned Productions Limited Consulting http://www.nedproductions.biz/ http://ie.linkedin.com/in/nialldouglas/