.. _program_listing_file_include_flamegpu_detail_JitifyCache.h: Program Listing for File JitifyCache.h ====================================== |exhale_lsh| :ref:`Return to documentation for file ` (``include/flamegpu/detail/JitifyCache.h``) .. |exhale_lsh| unicode:: U+021B0 .. UPWARDS ARROW WITH TIP LEFTWARDS .. code-block:: cpp #ifndef INCLUDE_FLAMEGPU_DETAIL_JITIFYCACHE_H_ #define INCLUDE_FLAMEGPU_DETAIL_JITIFYCACHE_H_ #include #include #include #include #include #include namespace jitify2 { class KernelData; class LinkedProgramData; } // namespace jitify2 namespace flamegpu { namespace detail { class JitifyCache { struct CachedProgram { // dynamic header concatenated to kernel // We check this is an exact match before loading from cache std::string long_reference; std::string serialised_program; }; public: std::unique_ptr loadKernel( const std::string &func_name, const std::vector &template_args, const std::string &kernel_src, const std::string &dynamic_header); void useMemoryCache(bool yesno); bool useMemoryCache() const; void clearMemoryCache(); void useDiskCache(bool yesno); bool useDiskCache() const; static void clearDiskCache(); private: static std::unique_ptr buildProgram( const std::string &func_name, const std::vector &template_args, const std::string &kernel_src, const std::string &dynamic_header, const std::string &name_expression); std::map cache{}; mutable std::mutex cache_mutex; bool use_memory_cache; bool use_disk_cache; JitifyCache(); static std::mutex instance_mutex; public: static JitifyCache& getInstance(); // Public deleted creates better compiler errors JitifyCache(JitifyCache const&) = delete; void operator=(JitifyCache const&) = delete; }; } // namespace detail } // namespace flamegpu #endif // INCLUDE_FLAMEGPU_DETAIL_JITIFYCACHE_H_