blob: 1935c33c3c8fb1cf89291a1ce0f07359636d79f6 [file] [log] [blame]
#include "bmc/daemon_context_bmc.h"
#include <cstdint>
#include "bmc/scheduler_bmc.h"
#include "daemon_context.h"
#include "parse_text_proto.h"
#include "persistent_storage.h"
#include "scheduler_interface.h"
#include "absl/log/check.h"
#include "absl/synchronization/mutex.h"
#include "absl/time/time.h"
#include "boost/asio/io_context.hpp" // NOLINT(readability/boost)
namespace safepower_agent {
using boost::asio::io_context;
DaemonContextBMC::DaemonContextBMC()
: io_context_(1), // concurrency_hint 1
scheduler_(io_context_),
persistent_storage_manager_() {
epoch_ms_ = absl::ToUnixMillis(now());
}
DaemonContextBMC& DaemonContextBMC::Get() {
return static_cast<DaemonContextBMC&>(DaemonContext::Get());
}
SchedulerInterface& DaemonContextBMC::scheduler() { return scheduler_; }
PersistentStorageManager& DaemonContextBMC::persistent_storage_manager() {
absl::MutexLock lock(&persistent_storage_manager_mutex_);
if (!persistent_storage_manager_.has_value()) {
persistent_storage_manager_.emplace(
config().gpowerd_config().persistent_storage_config());
}
return *persistent_storage_manager_;
}
io_context& DaemonContextBMC::get_io_context() { return io_context_; }
uint64_t DaemonContextBMC::epoch_ms() { return epoch_ms_; }
} // namespace safepower_agent