Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 10 additions & 6 deletions src/duckdb/src/parallel/task_executor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
#include "duckdb/parallel/task_notifier.hpp"
#include "duckdb/parallel/task_scheduler.hpp"

#include <thread>

namespace duckdb {

TaskExecutor::TaskExecutor(TaskScheduler &scheduler)
Expand Down Expand Up @@ -38,14 +40,16 @@ void TaskExecutor::FinishTask() {
void TaskExecutor::WorkOnTasks() {
// repeatedly execute tasks until we are finished
shared_ptr<Task> task_from_producer;
while (scheduler.GetTaskFromProducer(*token, task_from_producer)) {
auto res = task_from_producer->Execute(TaskExecutionMode::PROCESS_ALL);
(void)res;
D_ASSERT(res != TaskExecutionResult::TASK_BLOCKED);
task_from_producer.reset();
}
// wait for all active tasks to finish
while (completed_tasks != total_tasks) {
if (scheduler.GetTaskFromProducer(*token, task_from_producer)) {
const auto res = task_from_producer->Execute(TaskExecutionMode::PROCESS_ALL);
std::ignore = res;
D_ASSERT(res != TaskExecutionResult::TASK_BLOCKED);
task_from_producer.reset();
} else {
std::this_thread::yield();
}
}

// check if we ran into any errors while checkpointing
Expand Down
Loading