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

in aserver support message.call_async #100

Open
swmy-coder opened this issue Dec 13, 2024 · 4 comments
Open

in aserver support message.call_async #100

swmy-coder opened this issue Dec 13, 2024 · 4 comments

Comments

@swmy-coder
Copy link

Hi all:
Now in aserver which use sdbusplus::async::context, how to support to get reply for message.call_async? Thanks

@williamspatrick
Copy link
Member

Your question isn't super clear; hopefully I'm answering the right question.

You should use the sdbusplus::async::proxy class to create a "proxy" object representing the remote instance you are trying to interact with. You can then use .call on the proxy to make an async method call. This is an example of doing that:

co_await systemd.call<ret_type>(ctx, "ListUnitFiles"))

Better yet is if you are interacting with interfaces which have an sdbusplus-YAML representation (such as those in phosphor-dbus-interfaces). The generator will make a type-safe client binding for you that you can call. In that case, the functions are named based on the dbus method name.

auto _ = co_await c.multiply(7, 6);

@swmy-coder
Copy link
Author

HI williamspatrick :
Thanks for your reply
My question is i need to call mulitple dbus method, and need these dbus method‘s execution is parallel.
sdbusplus::async::proxy is good to call one dbus method async, but it cannot apply to multiply dbus call async.
So i plan to call dbus method async multiply like message.call_async in sdbusplus::async::context, and do work in the callback. but in sdbusplus::async::context the callback cannot be called.

@williamspatrick
Copy link
Member

You can spawn the coroutine into the context. If you want to spawn multiple and then wait for them to complete, you can spawn them into an async_scope.

@swmy-coder
Copy link
Author

Thanks~, It's worked

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

2 participants