MCPcopy Create free account
hub / github.com/NVIDIA/DALI / AddTask

Method AddTask

include/dali/core/exec/thread_pool_base.h:399–421  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

397template <bool cooperative>
398template <typename Runnable>
399std::enable_if_t<std::is_convertible_v<Runnable, std::function<void()>>>
400IncrementalJobImpl<cooperative>::AddTask(Runnable &&runnable) {
401 if (this->wait_started_)
402 throw std::logic_error("This job has already been waited for - cannot add more tasks to it");
403
404 auto it = tasks_.emplace(tasks_.end(), Task());
405 try {
406 it->func = [this, task = &*it, f = std::move(runnable)]() noexcept {
407 try {
408 f();
409 } catch (...) {
410 task->error = std::current_exception();
411 }
412
413 if (--this->num_pending_tasks_ == 0)
414 this->DoNotify();
415 };
416 this->total_tasks_++;
417 } catch (...) { // if, for whatever reason, we cannot initialize the task, we should erase it
418 tasks_.erase(it);
419 throw;
420 }
421}
422
423template <bool cooperative>
424template <typename Executor>

Callers 2

AddWorkMethod · 0.45
RunMethod · 0.45

Calls 6

emplaceMethod · 0.80
DoNotifyMethod · 0.80
TaskClass · 0.70
fFunction · 0.50
endMethod · 0.45
eraseMethod · 0.45

Tested by

no test coverage detected