MayaFlux 0.5.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches

◆ drain_pending_tasks()

void MayaFlux::Vruta::TaskScheduler::drain_pending_tasks ( )
private

Drain pending task operations (additions/removals) before processing.

This method ensures that any tasks that were added or removed while processing are properly handled before the next processing cycle.

Definition at line 583 of file Scheduler.cpp.

584{
585 if (m_pending_count.load(std::memory_order_relaxed) == 0)
586 return;
587
588 for (auto& op : m_pending_ops) {
589 if (!op.active.load(std::memory_order_acquire))
590 continue;
591
592 if (op.is_addition) {
593 auto existing_it = find_task_by_name(op.entry.name);
594 if (existing_it != m_tasks.end()) {
595 if (existing_it->routine && existing_it->routine->is_active())
596 existing_it->routine->set_should_terminate(true);
597 m_tasks.erase(existing_it);
598 }
599 m_tasks.push_back(std::move(op.entry));
600 } else {
601 auto it = find_task_by_name(op.entry.name);
602 if (it != m_tasks.end()) {
603 if (it->routine && it->routine->is_active())
604 it->routine->set_should_terminate(true);
605 m_tasks.erase(it);
606 }
607 }
608
609 op.entry = { nullptr, "" };
610 op.active.store(false, std::memory_order_release);
611 m_pending_count.fetch_sub(1, std::memory_order_relaxed);
612 }
613}
std::atomic< uint32_t > m_pending_count
std::vector< TaskEntry > m_tasks
PendingTaskOp m_pending_ops[MAX_PENDING_TASKS]
std::vector< TaskEntry >::iterator find_task_by_name(const std::string &name)
Find task entry by name.

References find_task_by_name(), m_pending_count, m_pending_ops, and m_tasks.

Referenced by get_all_tasks(), process_buffer_cycle_tasks(), process_token(), and terminate_all_tasks().

+ Here is the call graph for this function:
+ Here is the caller graph for this function: