#include #include #include #include #include #include #include using sdeventplus::Clock; using sdeventplus::ClockId; using sdeventplus::Event; using sdeventplus::source::Time; int main(int argc, char* argv[]) { if (argc != 2) { fprintf(stderr, "Usage: %s [seconds]\n", argv[0]); return 1; } unsigned interval = std::stoul(argv[1]); fprintf(stderr, "Beating every %u seconds\n", interval); auto event = Event::get_default(); auto hbFunc = [interval](Time& source, Time::TimePoint time) { printf("Beat\n"); source.set_time(time + std::chrono::seconds{interval}); }; Time time(event, Clock(event).now(), std::chrono::seconds{1}, std::move(hbFunc)); time.set_enabled(SD_EVENT_ON); return event.loop(); }