Added missing wait_for logic in RemoteLibrary

This commit is contained in:
casey langen 2020-10-27 22:00:58 -07:00
parent 7da49b1981
commit 1258c2803e
2 changed files with 7 additions and 2 deletions

View File

@ -46,6 +46,7 @@
#include <musikcore/runtime/Message.h>
#include <musikcore/debug.h>
#include <nlohmann/json.hpp>
#include <chrono>
static const std::string TAG = "RemoteLibrary";
@ -54,6 +55,7 @@ using namespace musik::core::db;
using namespace musik::core::library;
using namespace musik::core::net;
using namespace musik::core::runtime;
using namespace std::chrono;
#define MESSAGE_QUERY_COMPLETED 5000
#define MESSAGE_RECONNECT_SOCKET 5001
@ -206,7 +208,10 @@ int RemoteLibrary::EnqueueAndWait(QueryPtr query, int64_t timeoutMs, Callback ca
this->IsQueryInFlight(context->query) &&
!isQueryDone(context->query))
{
this->syncQueryCondition.wait(lock);
auto result = this->syncQueryCondition.wait_for(lock, timeoutMs * milliseconds(1));
if (result == std::cv_status::timeout) {
break;
}
}
}

View File

@ -54,7 +54,7 @@ using namespace musik::core::library::query;
using namespace musik::core::sdk;
static const size_t kDefaultCacheSize = 50;
static const int64_t kCacheWindowTimeoutMs = 50LL;
static const int64_t kCacheWindowTimeoutMs = 100LL;
TrackList::TrackList(ILibraryPtr library)
: library(library)