/* * Copyright (c) Facebook, Inc. and its affiliates. * * This software may be used and distributed according to the terms of the * GNU General Public License version 2. */ #pragma once #include #include #include #include "eden/fs/config/gen-cpp2/eden_config_types.h" namespace facebook { namespace eden { class EdenConfig; /** * An interface that defines how to obtain a possibly reloaded EdenConfig * instance. */ class ReloadableConfig { public: explicit ReloadableConfig(std::shared_ptr config); ~ReloadableConfig(); /** * Get the EdenConfig data. * * The config data may be reloaded from disk depending on the value of the * reload parameter. */ std::shared_ptr getEdenConfig( ConfigReloadBehavior reload = ConfigReloadBehavior::AutoReload); private: struct ConfigState { explicit ConfigState(const std::shared_ptr& config) : config{config} {} std::shared_ptr config; }; folly::Synchronized state_; std::atomic lastCheck_; }; } // namespace eden } // namespace facebook