Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Consider unsafe aio API #1732

Open
gdamore opened this issue Dec 17, 2023 · 0 comments
Open

Consider unsafe aio API #1732

gdamore opened this issue Dec 17, 2023 · 0 comments

Comments

@gdamore
Copy link
Contributor

gdamore commented Dec 17, 2023

We have a nice way to do inline AIOs for structs -- this API is more efficient because it avoids touching the allocator, and reduces the number of things we have to check for. (Initialization cannot fail.)

This inline API is not available for applications because it's a risk for binary compatibility -- if the AIO struct changes, then the application will need to be recompiled.

Still, this offers such a significant benefit to applications that I think it's worth enabling them to do this, provided that they opt-in to the safety considerations.

Basically, we'd expose the aio (at least size and alignment if not actual names) struct in a new header (maybe nng_unsafe.h) or possibly only exposed with a feature test macro (NNG_UNSAFE_API), along with functions to initialize and finalize it. Something like this:

// details of nng_aio struct TBD
extern void nng_aio_inline_init(nng_aio *, nng_cb, void *);
extern void nng_aio_inline_fini(nng_aio *);

The documentation would need to make very clear the risks of embedding this in structures.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant