[nanomsg] Re: [Non-DoD Source] async aio framework exposed to apps in nng

  • From: "Karan, Cem F CIV USARMY RDECOM ARL (US)" <cem.f.karan.civ@xxxxxxxx>
  • To: "nanomsg@xxxxxxxxxxxxx" <nanomsg@xxxxxxxxxxxxx>
  • Date: Thu, 26 Oct 2017 13:36:24 +0000

Nice!  Quick question; are messages always sent in the same order as they were 
queued up by the AIO interface?  

Thanks,
Cem Karan

---
Other than quoted laws, regulations or officially published policies, the views 
expressed herein are not intended to be used as an authoritative state of the 
law nor do they reflect official positions of the U.S. Army, Department of 
Defense or U.S. Government.


-----Original Message-----
From: nanomsg-bounce@xxxxxxxxxxxxx [mailto:nanomsg-bounce@xxxxxxxxxxxxx] On ;
Behalf Of Garrett D'Amore
Sent: Wednesday, October 25, 2017 9:44 PM
To: nanomsg@xxxxxxxxxxxxx
Subject: [Non-DoD Source] [nanomsg] async aio framework exposed to apps in nng

(This is only for nng, not available for legacy nanomsg.)

I just pushed nng bug #45.  This changes the API.  The old event callback 
scheme is removed (it was pretty horrible actually), and I’m
exposing an “aio” framework.

The way aio’s work is that you allocate one (it’s like a handle) with a 
completion callback and a user supplied argument for the callback.

Then you can submit operations and get notified when they are complete later. 
 You can also wait on them to be complete.

E.g:

```
nng_aio *a;
void mycallback(void *);
void *myarg;

nng_aio_alloc(&a, mycallback, myarg);
nng_aio_set_timeout (a, 100);
nng_aio_set_message (a, msg);

nng_send_aio(s, a);

… asynchronously the message is sent, and the mycallback is executed.
… it can read the aio result via nng_aio_result (a);

Operations can also be canceled with nng_aio_cancel().

You can then do nng_aio_wait(a).

The details are for now in the nng.h header file.

Note that this is largely the same stuff I’m using *internally* in nng.  I 
figured that it was so useful to me that folks building other kinds of
async apps could use it.  For example, this could be used to integrate into 
an event loop or drive state machine transitions, etc.

Anyway, not sure how many of you might be poking at nng these days, but this 
was the major API change that I wanted to get through
before declaring a broader beta release.  I’d appreciate folks bang away at 
this.

I’m still going to try to get websocket and TLS support knocked out before 
*formal* beta. Oh, and I need to write a lot more docs. :-)

Enjoy!

 - Garrett

Attachment: smime.p7s
Description: S/MIME cryptographic signature

Other related posts: