mirror of
https://github.com/ciphervance/supercell-wx.git
synced 2025-10-30 23:30:04 +00:00
Update recent object dates when date is already cached
This commit is contained in:
parent
27ce694df8
commit
ca88d60a5d
1 changed files with 14 additions and 3 deletions
|
|
@ -165,13 +165,14 @@ AwsNexradDataProvider::GetTimePointsByDate(
|
||||||
|
|
||||||
std::vector<std::chrono::system_clock::time_point> timePoints {};
|
std::vector<std::chrono::system_clock::time_point> timePoints {};
|
||||||
|
|
||||||
logger_->debug("GetTimePointsByDate: {}", util::TimeString(date));
|
logger_->trace("GetTimePointsByDate: {}", util::TimeString(date));
|
||||||
|
|
||||||
std::shared_lock lock(p->objectsMutex_);
|
std::shared_lock lock(p->objectsMutex_);
|
||||||
|
|
||||||
// Is the date present in the date list?
|
// Is the date present in the date list?
|
||||||
if (std::find(p->objectDates_.cbegin(), p->objectDates_.cend(), day) ==
|
auto currentDateIterator =
|
||||||
p->objectDates_.cend())
|
std::find(p->objectDates_.cbegin(), p->objectDates_.cend(), day);
|
||||||
|
if (currentDateIterator == p->objectDates_.cend())
|
||||||
{
|
{
|
||||||
// Temporarily unlock mutex
|
// Temporarily unlock mutex
|
||||||
lock.unlock();
|
lock.unlock();
|
||||||
|
|
@ -197,6 +198,16 @@ AwsNexradDataProvider::GetTimePointsByDate(
|
||||||
std::back_inserter(timePoints),
|
std::back_inserter(timePoints),
|
||||||
[](const auto& object) { return object.first; });
|
[](const auto& object) { return object.first; });
|
||||||
|
|
||||||
|
// Unlock mutex, finished
|
||||||
|
lock.unlock();
|
||||||
|
|
||||||
|
// If we haven't updated the most recently queried dates yet, because the
|
||||||
|
// date was already cached, update
|
||||||
|
if (currentDateIterator != p->objectDates_.cend())
|
||||||
|
{
|
||||||
|
p->UpdateObjectDates(date);
|
||||||
|
}
|
||||||
|
|
||||||
return timePoints;
|
return timePoints;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue