This commit is contained in:
2025-11-11 18:10:06 +03:00
parent 90acf1ee8c
commit 08ad1e665b
6 changed files with 28 additions and 12 deletions

View File

@@ -598,15 +598,20 @@ public:
*_isDataUpdated = false;
// std::future<error_t> update_ft = std::async(std::launch::async, _updateFunc, stop_source.get_token());
std::future<error_t> update_ft =
std::async(std::launch::async, _updateFunc, _internalUpdatingStopSource.get_token());
std::future<error_t> update_ft = std::async(std::launch::async, _updateFunc, stop_source.get_token());
// std::future<error_t> update_ft =
// std::async(std::launch::async, _updateFunc, _internalUpdatingStopSource.get_token());
auto status = update_ft.wait_for(timeout);
if (status == std::future_status::ready) {
*_isDataUpdated = true;
_lastUpdateError = update_ft.get();
} else {
} else if (status == std::future_status::deferred) { // std::async was invoked in this thread, get result
_lastUpdateError = update_ft.get();
if (!_lastUpdateError) {
*_isDataUpdated = true;
}
} else { // timeout
stop_source.request_stop();
_lastUpdateError = MccTelemetryErrorCode::ERROR_DATA_TIMEOUT;
}
@@ -631,7 +636,7 @@ public:
return MccTelemetryErrorCode::ERROR_DATA_TIMEOUT;
}
std::lock_guard thread_lock{*_updateMutex};
// std::lock_guard thread_lock{*_updateMutex};
if (!_lastUpdateError) {
mcc_copy_telemetry_data(_data, tdata);