@@ -178,7 +178,10 @@ TEST_F(TestClockWakeup, no_wakeup_on_sim_time) {
178178TEST_F (TestClockWakeup, multiple_threads_wait_on_one_clock) {
179179 auto clock = std::make_shared<rclcpp::Clock>(RCL_ROS_TIME);
180180
181- std::vector<bool > thread_finished (10 , false );
181+ std::vector<std::atomic_bool> thread_finished (10 );
182+ for (std::atomic_bool & finished : thread_finished) {
183+ finished = false ;
184+ }
182185
183186 std::vector<std::thread> threads;
184187
@@ -196,7 +199,7 @@ TEST_F(TestClockWakeup, multiple_threads_wait_on_one_clock) {
196199 // wait a bit so all threads can execute the sleep_until
197200 std::this_thread::sleep_for (std::chrono::milliseconds (500 ));
198201
199- for (const bool & finished : thread_finished) {
202+ for (const std::atomic_bool & finished : thread_finished) {
200203 EXPECT_FALSE (finished);
201204 }
202205
@@ -207,7 +210,7 @@ TEST_F(TestClockWakeup, multiple_threads_wait_on_one_clock) {
207210 bool threads_finished = false ;
208211 while (!threads_finished && start_time + std::chrono::seconds (1 ) > cur_time) {
209212 threads_finished = true ;
210- for (const bool finished : thread_finished) {
213+ for (const std::atomic_bool & finished : thread_finished) {
211214 if (!finished) {
212215 threads_finished = false ;
213216 }
@@ -217,7 +220,7 @@ TEST_F(TestClockWakeup, multiple_threads_wait_on_one_clock) {
217220 cur_time = std::chrono::steady_clock::now ();
218221 }
219222
220- for (const bool finished : thread_finished) {
223+ for (const std::atomic_bool & finished : thread_finished) {
221224 EXPECT_TRUE (finished);
222225 }
223226
0 commit comments