Patrick Williams | bf0283a | 2023-08-19 07:18:04 -0500 | [diff] [blame^] | 1 | #include <net/poettering/Calculator/aserver.hpp> |
| 2 | #include <sdbusplus/async.hpp> |
| 3 | |
| 4 | class Calculator : |
| 5 | public sdbusplus::aserver::net::poettering::Calculator<Calculator> |
| 6 | { |
| 7 | public: |
| 8 | explicit Calculator(sdbusplus::async::context& ctx) : |
| 9 | sdbusplus::aserver::net::poettering::Calculator<Calculator>( |
| 10 | ctx, "/net/poettering/calculator"), |
| 11 | manager(ctx, "/") |
| 12 | { |
| 13 | ctx.spawn(startup()); |
| 14 | } |
| 15 | |
| 16 | private: |
| 17 | auto startup() -> sdbusplus::async::task<> |
| 18 | { |
| 19 | ctx.get_bus().request_name("net.poettering.Calculator"); |
| 20 | |
| 21 | while (1) |
| 22 | { |
| 23 | using namespace std::literals; |
| 24 | co_await sdbusplus::async::sleep_for(ctx, 10s); |
| 25 | |
| 26 | cleared(42); |
| 27 | } |
| 28 | co_return; |
| 29 | } |
| 30 | |
| 31 | sdbusplus::server::manager_t manager; |
| 32 | }; |
| 33 | |
| 34 | int main() |
| 35 | { |
| 36 | sdbusplus::async::context ctx; |
| 37 | [[maybe_unused]] Calculator c(ctx); |
| 38 | |
| 39 | ctx.run(); |
| 40 | |
| 41 | return 0; |
| 42 | } |