26using Path = FileWatcher::Path;
37 using Task = std::packaged_task<
ConfigPtr()>;
40 explicit ConfigLoader(
const Path& path)
47 ConfigLoader(
const ConfigLoader&
rhs) =
delete;
48 ConfigLoader& operator=(
const ConfigLoader&
rhs) =
delete;
51 ConfigLoader(ConfigLoader&&) =
delete;
52 ConfigLoader& operator=(ConfigLoader&&) =
delete;
57 return tq_.run([](Task&&
t) {
t(); });
59 void stop() { tq_.stop(); }
72 tq_.push(std::move(
task));
93 config_future_ = config_loader_.load();
100 if (path != config_loader_.path()) {
104 TOOLBOX_INFO <<
"config " << path <<
" updated (IN_CLOSE_WRITE)";
107 TOOLBOX_INFO <<
"config " << path <<
" updated (IN_DELETE_SELF)";
116 config_future_ = config_loader_.load();
120 if (config_future_.valid()) {
126 config_ = config_future_.get();
127 }
catch (
const std::exception& e) {
129 config_future_ = config_loader_.load();
136 ConfigLoader& config_loader_;
146 using namespace std::literals::string_literals;
153 ConfigLoader
config_loader{
"/tmp/inotify_test/files/foo.txt"};
182 }
catch (
const std::exception& e) {