This commit is contained in:
2025-11-19 12:02:43 +03:00
parent c6b47d8ad6
commit 6214b82a6c
6 changed files with 797 additions and 627 deletions

View File

@@ -391,6 +391,29 @@ public:
return MccTelemetryErrorCode::ERROR_OK;
};
// update thread
// _updatingFuture = std::async(
// std::launch::async,
// [this](std::stop_token stoken) {
// while (!stoken.stop_requested()) {
// {
// std::unique_lock ulock{*_updateMutex};
// bool ok = _updateCondVar->wait(ulock, [&stoken, this]() -> bool {
// return _dataUpdatingRequested || stoken.stop_requested();
// });
// }
// if (!stoken.stop_requested()) {
// std::lock_guard lock{*_timeoutMutex};
// _lastUpdateError = _updateFunc(stoken);
// }
// }
// },
// _internalUpdatingStopSource.get_token());
}
@@ -712,18 +735,15 @@ protected:
std::chrono::nanoseconds _currentUpdateTimeout{defaultInternalUpdateTimeout};
std ::function<error_t(std::stop_token)> _updateTargetFunc{};
// std ::function<error_t(bool, std::stop_token)> _updateTargetFunc{};
std::function<error_t(std::stop_token)> _updateFunc{};
std::function<error_t()> _setTargetFunc{};
std::unique_ptr<std::mutex> _updateMutex;
std::unique_ptr<std::condition_variable> _updateCondVar;
// std::future<void> _internalUpdatingLoopFuture{};
// std::unique_ptr<std::mutex> _internalUpdatingLoopMutex{new std::mutex()};
// std::unique_ptr<std::condition_variable> _internalUpdatingLoopCondVar{new std::condition_variable()};
// std::unique_ptr<std::atomic_bool> _internalUpdatingLoopStop{new std::atomic_bool{false}};
// std::unique_ptr<std::atomic_bool> _dataUpdatingRequested{new std::atomic_bool{false}};
std::future<void> _updatingFuture{};
std::unique_ptr<std::atomic_bool> _dataUpdatingRequested{new std::atomic_bool{false}};
std::unique_ptr<std::timed_mutex> _timeoutMutex{new std::timed_mutex()};
error_t _lastUpdateError{MccTelemetryErrorCode::ERROR_OK};
};