Terminate and clear all tasks.
338{
340 if (entry.routine && entry.routine->is_active()) {
341 entry.routine->set_should_terminate(true);
342 }
343 }
344
346 if (entry.routine && entry.routine->is_active()) {
347 entry.routine->force_resume();
348 }
349 }
350
351 constexpr int MAX_ATTEMPTS = 3;
352 for (int attempt = 0; attempt < MAX_ATTEMPTS; ++attempt) {
353 std::this_thread::sleep_for(std::chrono::milliseconds(5));
354
355 bool any_active = false;
357 if (entry.routine && entry.routine->is_active()) {
358 any_active = true;
359 entry.routine->force_resume();
360 }
361 }
362
363 if (!any_active) {
364 break;
365 }
366 }
367
368 bool all_done = true;
369 for (
const auto& entry :
m_tasks) {
370 if (entry.routine && entry.routine->is_active()) {
371 all_done = false;
373 "Coroutine '{}' stuck after {} attempts - forcing destruction",
374 entry.name, MAX_ATTEMPTS);
375 }
376 }
377
378 if (!all_done) {
380 "Some coroutines did not complete - forcing destruction");
381 } else {
383 "All coroutines terminated successfully");
384 }
385
387}
#define MF_PRINT(comp, ctx,...)
#define MF_WARN(comp, ctx,...)
std::vector< TaskEntry > m_tasks
@ CoroutineScheduling
Coroutine scheduling and temporal coordination (Vruta::TaskScheduler)
@ Vruta
Coroutines, schedulers, clocks, task management.