Skip to content

Consider unsafe aio API #1732

Open
Open
@gdamore

Description

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions