MCPcopy Create free account
hub / github.com/RichieSams/FiberTaskingLib / AddTask

Method AddTask

source/task_scheduler.cpp:420–439  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

418}
419
420void TaskScheduler::AddTask(Task task, TaskPriority priority, WaitGroup *waitGroup) {
421 FTL_ASSERT("Task given to TaskScheduler:AddTask has a nullptr Function", task.Function != nullptr);
422
423 if (waitGroup != nullptr) {
424 waitGroup->Add(1);
425 }
426
427 const TaskBundle bundle = { task, waitGroup };
428 if (priority == TaskPriority::High) {
429 m_tls[GetCurrentThreadIndex()].HiPriTaskQueue.Push(bundle);
430 } else if (priority == TaskPriority::Normal) {
431 m_tls[GetCurrentThreadIndex()].LoPriTaskQueue.Push(bundle);
432 }
433
434 const EmptyQueueBehavior behavior = m_emptyQueueBehavior.load(std::memory_order_relaxed);
435 if (behavior == EmptyQueueBehavior::Sleep) {
436 // Wake a sleeping thread
437 ThreadSleepCV.notify_one();
438 }
439}
440
441void TaskScheduler::AddTasks(uint32_t numTasks, Task *tasks, TaskPriority priority, WaitGroup *waitGroup) {
442 if (waitGroup != nullptr) {

Callers 3

fibtex.cppFile · 0.80
ParallelForFunction · 0.80

Calls 2

AddMethod · 0.80
PushMethod · 0.80

Tested by

no test coverage detected