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 @@ -129,8 +129,14 @@ RobotClient::~RobotClient() {
129129
130130void RobotClient::close () {
131131 should_refresh_.store (false );
132+
133+ for (auto & thread : threads_) {
134+ thread.join ();
135+ }
132136 threads_.clear ();
137+
133138 stop_all ();
139+
134140 viam_channel_.close ();
135141}
136142
@@ -289,13 +295,8 @@ std::shared_ptr<RobotClient> RobotClient::with_channel(ViamChannel channel,
289295 robot->refresh_interval_ = options.refresh_interval ();
290296 robot->should_refresh_ = (robot->refresh_interval_ > 0 );
291297 if (robot->should_refresh_ ) {
292- auto t = std::thread (&RobotClient::refresh_every, robot);
293- // TODO(RSDK-1743): this was leaking, confirm that adding thread catching in
294- // close/destructor lets us shutdown gracefully. See also address sanitizer,
295- // UB sanitizer
296- t.detach ();
297- robot->threads_ .push_back (std::move (t));
298- };
298+ robot->threads_ .emplace_back (&RobotClient::refresh_every, robot);
299+ }
299300
300301 robot->refresh ();
301302 return robot;
You can’t perform that action at this time.
0 commit comments