Brad Bishop | e55ef3d | 2016-12-19 09:12:40 -0500 | [diff] [blame] | 1 | #pragma once |
| 2 | |
Brad Bishop | d499ca6 | 2016-12-19 09:24:50 -0500 | [diff] [blame^] | 3 | #include <string> |
| 4 | |
| 5 | /** @class MainLoop |
| 6 | * @brief hwmon-readd main application loop. |
| 7 | */ |
| 8 | class MainLoop |
| 9 | { |
| 10 | public: |
| 11 | MainLoop() = delete; |
| 12 | MainLoop(const MainLoop&) = delete; |
| 13 | MainLoop& operator=(const MainLoop&) = delete; |
| 14 | MainLoop(MainLoop&&) = default; |
| 15 | MainLoop& operator=(MainLoop&&) = default; |
| 16 | ~MainLoop() = default; |
| 17 | |
| 18 | /** @brief Constructor |
| 19 | * |
| 20 | * @param[in] path - hwmon sysfs instance to manage |
| 21 | */ |
| 22 | explicit MainLoop(const std::string& path); |
| 23 | |
| 24 | /** @brief Start polling loop and process dbus traffic. */ |
| 25 | void run(); |
| 26 | |
| 27 | /** @brief Stop loop from another thread. |
| 28 | * |
| 29 | * Typically only used by testcases. |
| 30 | */ |
| 31 | void shutdown() noexcept; |
| 32 | |
| 33 | private: |
| 34 | |
| 35 | /** @brief Shutdown requested. */ |
| 36 | volatile bool _shutdown; |
| 37 | /** @brief Path to hwmon sysfs instance. */ |
| 38 | std::string _path; |
| 39 | }; |