Still a long way to go but I just felt like sharing.

Still a long way to go but I just felt like sharing.

AsyncIO library is a library for asynchronous IO. It's inspired by Boost.ASIO, and uses IO Completion Ports (IOCP) under the hood. However the idea is to keep it pretty well wrapped up, so porting to other implementations should be possible at a later stage.

A just-for-fun project for now, but hoping it'll be useful one day.

So far I've implemented:
- The IOCP core.
- Async stream read/write functions, to transfer a minimum or an exact number of bytes from an async stream (AsyncRead/AsyncWrite).
- Async file IO (AsyncFileStream).
- Async TCP socket (TCPSocket) and async socket IO (AsyncSocketStream).

Thanks again to Stefan Glienke for making TestInsight, which I've used actively in this project as well. I'm a n00b as far as unit/integration testing goes to that might show, but with TestInsight it finally feels fun to write tests.

As mentioned lots of work remains. I've spent the last weeks improving test coverage, so I could prepare for a bit of refactoring.

Thread safety is planned but not implemented. I will focus on this soon, but felt I needed to flesh out the library a bit first so I had some idea of what is required.
https://github.com/lordcrc/AsyncIO

Comments

  1. How does it compare to DIOCP (https://github.com/ymofen/diocp-v5)?  DIOCP is by the same Chinese programmer who developed msgpack-delphi

    ReplyDelete
  2. Edwin Yip Well... good question :) I admit I did not know of DIOCP until you mentioned it.

    Objectively:
    - DIOCP is definitely more fleshed out, my AsyncIO is still in it's infancy.

    - AsyncIO uses more modern constructs and patters. For example, async operation handlers are "reference to procedure", and it uses interfaces or records to avoid manual memory management. DIOCP seems to be "classic" there, with TObject and raw pointers being the norm.

    - AsyncIO socket code supports IPv6 and IPv4 (modulo bugs). DIOCP socket code is strictly IPv4.

    - DIOCP has no unit/integration tests it seems. AsyncIO should have fairly decent test coverage.

    Personally I had a really hard time understanding the examples and implementation of DIOCP. But that could just be me of course.

    I know AsyncIO is void of documentation right now and as such may appear similarly opaque, so this is something I plan to rectify very soon.

    ReplyDelete
  3. Asbjørn Heid The author of DIOCP is not active in the English community, and I guess that's why you did not know it, anyway a Google search still reveals it's existence :D But you are doing a great job, really!

    ReplyDelete
  4. Edwin Yip Thanks. Unfortunately the Delphi community is fairly fragmented by language barriers. In any case, I admit I didn't do much reseach before starting this, as I've always wanted to do IOCP from the ground up :)

    ReplyDelete
  5. No attempt to make it cross-platform, using FPC? IOCP is great under Linux, using e.g. libevent or libpoll.

    ReplyDelete
  6. A. Bouchez Not yet no. 

    Mainly for two reasons: I'm not familiar with epoll, kqueue or similar at all, and FPC was tedious to use last time I tried (a year ago) so never went further with it. Both are rather hard limitations due to available spare time.

    But as I said, I'm trying to keep things abstracted so should be possible, assuming FPC can do anonymous functions.

    ReplyDelete

Post a Comment