blob: 10edd34e687572fb1aa4380338b0ed44931df4e7 [file] [log] [blame] [edit]
#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/scheduler_bmc.h"
#include "daemon_context.h"
#include "persistent_storage.h"
#include "persistent_storage_impl.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::PersistentStorageManagerImpl>
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_