mirror of
https://github.com/MaskRay/ccls.git
synced 2024-11-29 19:07:08 +00:00
3599a831b1
Only the initialize request uses it so far, but this will enable pulling quite a bit of code out of command_line.cc.
27 lines
757 B
C++
27 lines
757 B
C++
#include "timestamp_manager.h"
|
|
|
|
#include "indexer.h"
|
|
|
|
optional<int64_t> TimestampManager::GetLastCachedModificationTime(
|
|
CacheLoader* cache_loader,
|
|
const std::string& path) {
|
|
{
|
|
std::lock_guard<std::mutex> guard(mutex_);
|
|
auto it = timestamps_.find(path);
|
|
if (it != timestamps_.end())
|
|
return it->second;
|
|
}
|
|
IndexFile* file = cache_loader->TryLoad(path);
|
|
if (!file)
|
|
return nullopt;
|
|
|
|
UpdateCachedModificationTime(path, file->last_modification_time);
|
|
return file->last_modification_time;
|
|
}
|
|
|
|
void TimestampManager::UpdateCachedModificationTime(const std::string& path,
|
|
int64_t timestamp) {
|
|
std::lock_guard<std::mutex> guard(mutex_);
|
|
timestamps_[path] = timestamp;
|
|
}
|