MayaFlux 0.4.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 591 of file Scheduler.cpp.

592{
593 if (m_pending_count.load(std::memory_order_relaxed) == 0)
594 return;
595
596 for (auto& op : m_pending_ops) {
597 if (!op.active.load(std::memory_order_acquire))
598 continue;
599
600 if (op.is_addition) {
601 auto existing_it = find_task_by_name(op.entry.name);
602 if (existing_it != m_tasks.end()) {
603 if (existing_it->routine && existing_it->routine->is_active())
604 existing_it->routine->set_should_terminate(true);
605 m_tasks.erase(existing_it);
606 }
607 m_tasks.push_back(std::move(op.entry));
608 } else {
609 auto it = find_task_by_name(op.entry.name);
610 if (it != m_tasks.end()) {
611 if (it->routine && it->routine->is_active())
612 it->routine->set_should_terminate(true);
613 m_tasks.erase(it);
614 }
615 }
616
617 op.entry = { nullptr, "" };
618 op.active.store(false, std::memory_order_release);
619 m_pending_count.fetch_sub(1, std::memory_order_relaxed);
620 }
621}
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: