@@ -81,7 +81,7 @@ class TestExecutors : public ::testing::Test
8181 rclcpp::Node::SharedPtr node;
8282 rclcpp::Publisher<test_msgs::msg::Empty>::SharedPtr publisher;
8383 rclcpp::Subscription<test_msgs::msg::Empty>::SharedPtr subscription;
84- int callback_count;
84+ std::atomic< int > callback_count;
8585};
8686
8787template <typename T>
@@ -152,7 +152,7 @@ TYPED_TEST(TestExecutors, spinWithTimer)
152152 using ExecutorType = TypeParam;
153153 ExecutorType executor;
154154
155- bool timer_completed = false ;
155+ std::atomic< bool > timer_completed = false ;
156156 auto timer = this ->node ->create_wall_timer (1ms, [&]() {timer_completed = true ;});
157157 executor.add_node (this ->node );
158158
@@ -263,7 +263,7 @@ TYPED_TEST(TestExecutors, testSpinUntilFutureCompleteNoTimeout)
263263 }
264264 });
265265
266- bool spin_exited = false ;
266+ std::atomic< bool > spin_exited = false ;
267267
268268 // Timeout set to negative for no timeout.
269269 std::thread spinner ([&]() {
@@ -300,7 +300,7 @@ TYPED_TEST(TestExecutors, testSpinUntilFutureCompleteWithTimeout)
300300 ExecutorType executor;
301301 executor.add_node (this ->node );
302302
303- bool spin_exited = false ;
303+ std::atomic< bool > spin_exited = false ;
304304
305305 // Needs to run longer than spin_until_future_complete's timeout.
306306 std::future<void > future = std::async (
@@ -344,7 +344,7 @@ TYPED_TEST(TestExecutors, spinAll)
344344
345345 // Long timeout, but should not block test if spin_all works as expected as we cancel the
346346 // executor.
347- bool spin_exited = false ;
347+ std::atomic< bool > spin_exited = false ;
348348 std::thread spinner ([&spin_exited, &executor, this ]() {
349349 executor.spin_all (1s);
350350 executor.remove_node (this ->node , true );
@@ -586,7 +586,7 @@ TYPED_TEST(TestExecutors, testSpinUntilFutureCompleteInterrupted)
586586 ExecutorType executor;
587587 executor.add_node (this ->node );
588588
589- bool spin_exited = false ;
589+ std::atomic< bool > spin_exited = false ;
590590
591591 // This needs to block longer than it takes to get to the shutdown call below and for
592592 // spin_until_future_complete to return
0 commit comments