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

◆ cancel_task() [2/2]

bool MayaFlux::Vruta::TaskScheduler::cancel_task ( const std::string &  name)

Cancel a task by name.

Parameters
nameTask name to cancel
Returns
True if found and cancelled

Definition at line 149 of file Scheduler.cpp.

150{
151 SubmissionGuard guard(m_inflight_submissions, m_terminating);
152 if (!guard.accepted)
153 return false;
154
155 bool queued = false;
156
157 if (m_conditional_thread.joinable()) {
158 for (auto& op : m_conditional_pending_ops) {
159 bool expected = false;
160 if (op.active.compare_exchange_strong(expected, true,
161 std::memory_order_acquire, std::memory_order_relaxed)) {
162 op.entry = { nullptr, name };
163 op.is_addition = false;
164 m_conditional_pending_count.fetch_add(1, std::memory_order_relaxed);
165 queued = true;
166 break;
167 }
168 }
169 }
170
171 for (auto& op : m_pending_ops) {
172 bool expected = false;
173 if (op.active.compare_exchange_strong(expected, true,
174 std::memory_order_acquire, std::memory_order_relaxed)) {
175 op.entry = { nullptr, name };
176 op.is_addition = false;
177 m_pending_count.fetch_add(1, std::memory_order_relaxed);
178 queued = true;
179 break;
180 }
181 }
182
183 if (!queued) {
185 "Pending task queue full, could not cancel task '{}'", name);
186 }
187
188 return queued;
189}
#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::atomic< uint32_t > m_conditional_pending_count
PendingTaskOp m_pending_ops[MAX_PENDING_TASKS]
std::atomic< uint32_t > m_inflight_submissions
PendingTaskOp m_conditional_pending_ops[MAX_PENDING_CONDITIONAL]
@ CoroutineScheduling
Coroutine scheduling and temporal coordination (Vruta::TaskScheduler)
@ Vruta
Coroutines, schedulers, clocks, task management.

References MayaFlux::Journal::CoroutineScheduling, m_conditional_pending_count, m_conditional_pending_ops, m_conditional_thread, m_inflight_submissions, m_pending_count, m_pending_ops, m_terminating, MF_ERROR, name, and MayaFlux::Journal::Vruta.