| #ifndef THIRD_PARTY_MILOTIC_EXTERNAL_CC_TLBMC_HAL_SHARED_MEM_STATIC_SHM_COMMON_H |
| #define THIRD_PARTY_MILOTIC_EXTERNAL_CC_TLBMC_HAL_SHARED_MEM_STATIC_SHM_COMMON_H |
| |
| #include "absl/base/no_destructor.h" |
| #include "boost/interprocess/managed_shared_memory.hpp" //NOLINT |
| // copybara:strip_begin(g3-shared-libs) |
| #include "tlbmc/hal/shared_mem/metrics.h" |
| // copybara:strip_end |
| namespace milotic_tlbmc { |
| constexpr const char* kStaticShmInitializedFile = |
| "/run/tlbmc/static_shm_initialized"; |
| |
| constexpr const char* kStaticShmName = "TlbmcStaticSharedMemory"; |
| |
| /* |
| * The convention that all objects other than sensor names are prefixed with |
| * "__". This is to allow for future extensibility and make finding the sensors |
| * at load time robust. |
| */ |
| // copybara:strip_begin(g3-shared-libs) |
| // Removed kMetricsObjectName as metrics are now in-process. |
| // copybara:strip_end |
| |
| using TlbmcSharedMemoryType = boost::interprocess::basic_managed_shared_memory< |
| char, |
| boost::interprocess::rbtree_best_fit< |
| boost::interprocess::null_mutex_family>, |
| boost::interprocess::iset_index>; |
| |
| // copybara:strip_begin(g3-shared-libs) |
| class StaticSharedMemoryMetrics { |
| public: |
| static TlbmcMetrics* GetInProcessMetrics() { |
| static absl::NoDestructor<TlbmcMetrics> in_process_metrics; |
| return in_process_metrics.get(); |
| } |
| static void ResetForTesting() { GetInProcessMetrics()->ResetForUnitTest(); } |
| }; |
| // copybara:strip_end |
| } // namespace milotic_tlbmc |
| #endif // THIRD_PARTY_MILOTIC_EXTERNAL_CC_TLBMC_HAL_SHARED_MEM_STATIC_SHM_COMMON_H |