1 #pragma once 2 3 #include <optional.h> 4 5 #include <mutex> 6 #include <unordered_map> 7 8 struct ICacheManager; 9 10 // Caches timestamps of cc files so we can avoid a filesystem reads. This is 11 // important for import perf, as during dependency checking the same files are 12 // checked over and over again if they are common headers. 13 struct TimestampManager { 14 optional<int64_t> GetLastCachedModificationTime(ICacheManager* cache_manager, 15 const std::string& path); 16 17 void UpdateCachedModificationTime(const std::string& path, int64_t timestamp); 18 19 // TODO: use std::shared_mutex so we can have multiple readers. 20 std::mutex mutex_; 21 std::unordered_map<std::string, int64_t> timestamps_; 22 };