From ca88d60a5dfce1a0e904311f0639ba44d7b70615 Mon Sep 17 00:00:00 2001 From: Dan Paulat Date: Fri, 26 May 2023 01:14:42 -0500 Subject: [PATCH] Update recent object dates when date is already cached --- .../scwx/provider/aws_nexrad_data_provider.cpp | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/wxdata/source/scwx/provider/aws_nexrad_data_provider.cpp b/wxdata/source/scwx/provider/aws_nexrad_data_provider.cpp index 2960a3df..6c749e82 100644 --- a/wxdata/source/scwx/provider/aws_nexrad_data_provider.cpp +++ b/wxdata/source/scwx/provider/aws_nexrad_data_provider.cpp @@ -165,13 +165,14 @@ AwsNexradDataProvider::GetTimePointsByDate( std::vector timePoints {}; - logger_->debug("GetTimePointsByDate: {}", util::TimeString(date)); + logger_->trace("GetTimePointsByDate: {}", util::TimeString(date)); std::shared_lock lock(p->objectsMutex_); // Is the date present in the date list? - if (std::find(p->objectDates_.cbegin(), p->objectDates_.cend(), day) == - p->objectDates_.cend()) + auto currentDateIterator = + std::find(p->objectDates_.cbegin(), p->objectDates_.cend(), day); + if (currentDateIterator == p->objectDates_.cend()) { // Temporarily unlock mutex lock.unlock(); @@ -197,6 +198,16 @@ AwsNexradDataProvider::GetTimePointsByDate( std::back_inserter(timePoints), [](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; }