blob: 04a4d18367e2afc2c4f6d03b74239c1a3afd4d77 [file] [log] [blame]
#ifndef PRODUCTION_BORG_MGMT_NODE_PROXY_SAFEPOWER_SAFEPOWER_AGENT_BMC_DAEMON_CONTEXT_BMC_H_
#define PRODUCTION_BORG_MGMT_NODE_PROXY_SAFEPOWER_SAFEPOWER_AGENT_BMC_DAEMON_CONTEXT_BMC_H_
#include <cstdint>
#include <optional>
#include "bmc/persistent_storage_bmc.h"
#include "bmc/scheduler_bmc.h"
#include "daemon_context.h"
#include "persistent_storage.h"
#include "scheduler_interface.h"
#include "absl/base/thread_annotations.h"
#include "absl/synchronization/mutex.h"
#include "boost/asio/io_context.hpp" // NOLINT(readability/boost)
namespace safepower_agent {
using boost::asio::io_context;
class DaemonContextBMC : public DaemonContext {
public:
DaemonContextBMC();
SchedulerInterface& scheduler() override;
PersistentStorageManager& persistent_storage_manager() override;
uint64_t epoch_ms() override;
io_context& get_io_context();
DaemonContextBMC(DaemonContextBMC&& other) = delete;
DaemonContextBMC& operator=(DaemonContextBMC&& other) = delete;
// There is only one context so getter is static to enforce
static DaemonContextBMC& Get();
private:
io_context io_context_;
SchedulerBMC scheduler_;
absl::Mutex persistent_storage_manager_mutex_;
std::optional<persistent_storage::PersistentStorageManagerBMC>
persistent_storage_manager_
ABSL_GUARDED_BY(persistent_storage_manager_mutex_);
uint64_t epoch_ms_;
};
} // namespace safepower_agent
#endif // PRODUCTION_BORG_MGMT_NODE_PROXY_SAFEPOWER_SAFEPOWER_AGENT_BMC_DAEMON_CONTEXT_BMC_H_