2017-12-05 07:57:41 +00:00
|
|
|
#pragma once
|
|
|
|
|
2018-03-31 03:16:33 +00:00
|
|
|
#include <optional>
|
2017-12-05 07:57:41 +00:00
|
|
|
|
|
|
|
#include <mutex>
|
|
|
|
#include <unordered_map>
|
|
|
|
|
2017-12-29 17:27:56 +00:00
|
|
|
struct ICacheManager;
|
|
|
|
|
2017-12-05 07:57:41 +00:00
|
|
|
// Caches timestamps of cc files so we can avoid a filesystem reads. This is
|
|
|
|
// important for import perf, as during dependency checking the same files are
|
|
|
|
// checked over and over again if they are common headers.
|
|
|
|
struct TimestampManager {
|
2018-03-31 03:16:33 +00:00
|
|
|
std::optional<int64_t> GetLastCachedModificationTime(ICacheManager* cache_manager,
|
2017-12-05 07:57:41 +00:00
|
|
|
const std::string& path);
|
|
|
|
|
|
|
|
void UpdateCachedModificationTime(const std::string& path, int64_t timestamp);
|
|
|
|
|
|
|
|
// TODO: use std::shared_mutex so we can have multiple readers.
|
|
|
|
std::mutex mutex_;
|
|
|
|
std::unordered_map<std::string, int64_t> timestamps_;
|
|
|
|
};
|