Skip to content

[Question] How to pass a value or datas in the callback function of nng_aio_alloc? #1799

Answered by gdamore
alawn-wang asked this question in Q&A
Discussion options

You must be logged in to vote

So typically you set this up with nng_aio_alloc() -- the intention is that the void * parameter is one you (the consumer) supply, which can then be passed to the callback (in fact it's the first argument to the callback.)

It is possible to cheat and use the input or output parameters for a little bit of data (e.g. nng_aio_set_input() with a value of 4 or so, but generally speaking this is risky because the input and output callers are "owned" by the stack in the middle. Usually they only use the first 1 or 2.

(At one point I had an API for attaching other data to AIOs, but in very large scale systems this causes the memory use to bigger than I'd like, and its not strictly necessary with t…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@alawn-wang
Comment options

Answer selected by gdamore
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #1794 on March 17, 2024 01:54.