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

◆ cancel_task() [1/2]

bool MayaFlux::Vruta::TaskScheduler::cancel_task ( const std::shared_ptr< Routine > &  routine)

Cancels and removes a task from the scheduler.

Parameters
routineShared pointer to the task to cancel
Returns
True if the task was found and cancelled, false otherwise

This method removes a task from the scheduler, preventing it from executing further. It's used to stop tasks that are no longer needed or to clean up before shutting down the engine.

Definition at line 191 of file Scheduler.cpp.

192{
193 if (!routine)
194 return false;
195
196 SubmissionGuard guard(m_inflight_submissions, m_terminating);
197 if (!guard.accepted)
198 return false;
199
200 if (routine->get_processing_token() == ProcessingToken::CONDITIONAL) {
201 auto it = std::ranges::find_if(m_conditional_tasks,
202 [&routine](const TaskEntry& e) { return e.routine == routine; });
203 const std::string name = (it != m_conditional_tasks.end()) ? it->name : "";
204 return cancel_task(name);
205 }
206
207 auto it = find_task_by_routine(routine);
208 const std::string name = (it != m_tasks.end()) ? it->name : "";
209
210 for (auto& op : m_pending_ops) {
211 bool expected = false;
212 if (op.active.compare_exchange_strong(expected, true,
213 std::memory_order_acquire, std::memory_order_relaxed)) {
214 op.entry = { routine, name };
215 op.is_addition = false;
216 m_pending_count.fetch_add(1, std::memory_order_relaxed);
217 return true;
218 }
219 }
220
222 "Pending task queue full, could not cancel task '{}'", name);
223 return false;
224}
#define MF_ERROR(comp, ctx,...)
std::string name
Definition VKDevice.cpp:123
std::atomic< uint32_t > m_pending_count
std::atomic< bool > m_terminating
std::vector< TaskEntry > m_tasks
PendingTaskOp m_pending_ops[MAX_PENDING_TASKS]
std::vector< TaskEntry > m_conditional_tasks
std::atomic< uint32_t > m_inflight_submissions
bool cancel_task(const std::shared_ptr< Routine > &routine)
Cancels and removes a task from the scheduler.
std::vector< TaskEntry >::iterator find_task_by_routine(const std::shared_ptr< Routine > &routine)
Find task entry by routine pointer.
@ CoroutineScheduling
Coroutine scheduling and temporal coordination (Vruta::TaskScheduler)
@ Vruta
Coroutines, schedulers, clocks, task management.
@ CONDITIONAL
Condition-driven execution - resume when a caller-supplied predicate returns true.

References cancel_task(), MayaFlux::Vruta::CONDITIONAL, MayaFlux::Journal::CoroutineScheduling, find_task_by_routine(), m_conditional_tasks, m_inflight_submissions, m_pending_count, m_pending_ops, m_tasks, m_terminating, MF_ERROR, name, MayaFlux::Vruta::TaskEntry::routine, and MayaFlux::Journal::Vruta.

Referenced by MayaFlux::Kriya::EventChain::cancel(), MayaFlux::Kriya::Timer::cancel(), MayaFlux::Portal::Forma::Bridge::cancel_inbound(), MayaFlux::Portal::Forma::Bridge::cancel_outbound(), cancel_task(), MayaFlux::Kriya::BufferPipeline::end(), MayaFlux::Nexus::Fabric::remove(), MayaFlux::IO::SpatialCapture::stop(), MayaFlux::IO::VolumeCapture::stop(), MayaFlux::Portal::Forma::Bridge::stop_sync(), MayaFlux::Portal::Forma::Bridge::~Bridge(), and MayaFlux::Nexus::Fabric::~Fabric().

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