blob: 4bc08c416363ba810220c410de12d9cf85b12cf4 [file] [log] [blame]
Brad Bishope55ef3d2016-12-19 09:12:40 -05001#pragma once
2
Brad Bishopd499ca62016-12-19 09:24:50 -05003#include <string>
4
5/** @class MainLoop
6 * @brief hwmon-readd main application loop.
7 */
8class 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};