#pragma once #include #include "common.hpp" #include "utils/concurrency.hpp" POLYBAR_NS template class cache { public: using map_type = std::unordered_map>; using safe_map_type = mutex_wrapper; template shared_ptr object(const KeyType& key, MakeArgs&&... make_args) { std::lock_guard guard(m_cache); auto ptr = m_cache[key].lock(); if (!ptr) { m_cache[key] = ptr = make_shared(forward(make_args)...); } return ptr; } private: safe_map_type m_cache; }; namespace cache_util {} POLYBAR_NS_END