sdbusplus:通过connection::async_send以协程异步调用service的method_sdbusplus::asio::connection-CSDN博客
介绍了如何使用协程调用
实际上可以同时使用协程和异步调用,甚至多个协程
//calculate_1s.cpp
#include <sdbusplus/asio/connection.hpp>
#include <sdbusplus/asio/object_server.hpp>
#include <sdbusplus/bus.hpp>
#include <iostream>
#include <string>
using namespace std;
int addInt(int d1, int d2)
{
cout<<"begin sleep 1"<<endl;
sleep(1);
cout<<"end sleep 1"<<endl;
return d1 + d2;
}
string addString(string s1, string s2)
{
return s1 + s2;
}
int main()
{
boost::asio::io_context io;
auto conn = std::make_shared<sdbusplus::asio::connection>(io);