.. _program_listing_file__home_runner_work_Legion-Engine_Legion-Engine_legion_engine_core_filesystem_artifact_cache.hpp: Program Listing for File artifact_cache.hpp =========================================== |exhale_lsh| :ref:`Return to documentation for file ` (``/home/runner/work/Legion-Engine/Legion-Engine/legion/engine/core/filesystem/artifact_cache.hpp``) .. |exhale_lsh| unicode:: U+021B0 .. UPWARDS ARROW WITH TIP LEFTWARDS .. code-block:: cpp #pragma once #include #include #include #include #include namespace legion::core::filesystem { constexpr std::size_t gc_interval = 5; constexpr std::size_t gc_keep = 35; constexpr std::size_t gc_hist = 10; class artifact_cache { public: static std::shared_ptr get_cache(std::string_view identifier,std::size_t size_hint = 0); static artifact_cache& get_driver(); void gc(); private: artifact_cache() = default; auto& get_caches() { return m_caches; } size_t decrease_gcc() { const size_t countdown = m_gc_countdown.fetch_sub(1); return countdown-1; } std::atomic current_mean; std::unordered_map,int32_t>> m_caches; std::atomic m_gc_countdown = gc_interval; mutable async::rw_spinlock m_big_gc_lock; }; }