25 static inline Mutex mutex_;
27 mutable bool processor_created_ =
false;
28 mutable std::unique_ptr<const CPUProcessor> cpu_processor_;
46 const std::function<std::unique_ptr<CPUProcessor>()> &create_processor)
const
48 std::lock_guard
lock(mutex_);
50 if (!processor_created_) {
51 cpu_processor_ = create_processor();
52 processor_created_ =
true;
55 return cpu_processor_.get();
CPUProcessorCache & operator=(CPUProcessorCache &&other)=default
CPUProcessorCache & operator=(const CPUProcessorCache &other)=delete
~CPUProcessorCache()=default
CPUProcessorCache()=default
CPUProcessorCache(CPUProcessorCache &&other) noexcept=default
const CPUProcessor * get(const std::function< std::unique_ptr< CPUProcessor >()> &create_processor) const
CPUProcessorCache(const CPUProcessorCache &other)=delete