File tree Expand file tree Collapse file tree 1 file changed +8
-7
lines changed Expand file tree Collapse file tree 1 file changed +8
-7
lines changed Original file line number Diff line number Diff line change @@ -226,18 +226,19 @@ void RobotClient::refresh() {
226226void RobotClient::refresh_every () {
227227 std::unique_lock<std::mutex> lk{refresh_lock_};
228228
229- while ( true ) {
230- if (refresh_cv_. wait_for (lk, refresh_interval_) == std::cv_status::timeout ) {
229+ refresh_cv_. wait_for (lk, refresh_interval_, [ this ] {
230+ if (should_refresh_ ) {
231231 try {
232232 refresh ();
233233 } catch (const std::exception& e) {
234- VIAM_SDK_LOG (warn) << " Refresh thread terminated with exception: " << e.what ();
235- break ;
234+ VIAM_SDK_LOG (warn) << " Refresh thread got exception " << e.what ();
235+ // TODO: maybe recoverable
236+ return true ;
236237 }
237- } else if (should_refresh_ == false ) {
238- break ;
239238 }
240- }
239+
240+ return !should_refresh_;
241+ });
241242}
242243
243244RobotClient::RobotClient (ViamChannel channel)
You can’t perform that action at this time.
0 commit comments