1#include "duckdb/parallel/task.hpp"
2#include "duckdb/execution/executor.hpp"
3#include "duckdb/main/client_context.hpp"
4
5namespace duckdb {
6
7ExecutorTask::ExecutorTask(Executor &executor_p) : executor(executor_p) {
8}
9
10ExecutorTask::ExecutorTask(ClientContext &context) : ExecutorTask(Executor::Get(context)) {
11}
12
13ExecutorTask::~ExecutorTask() {
14}
15
16void ExecutorTask::Deschedule() {
17 auto this_ptr = shared_from_this();
18 executor.AddToBeRescheduled(task&: this_ptr);
19}
20
21void ExecutorTask::Reschedule() {
22 auto this_ptr = shared_from_this();
23 executor.RescheduleTask(task&: this_ptr);
24}
25
26TaskExecutionResult ExecutorTask::Execute(TaskExecutionMode mode) {
27 try {
28 return ExecuteTask(mode);
29 } catch (Exception &ex) {
30 executor.PushError(exception: PreservedError(ex));
31 } catch (std::exception &ex) {
32 executor.PushError(exception: PreservedError(ex));
33 } catch (...) { // LCOV_EXCL_START
34 executor.PushError(exception: PreservedError("Unknown exception in Finalize!"));
35 } // LCOV_EXCL_STOP
36 return TaskExecutionResult::TASK_ERROR;
37}
38
39} // namespace duckdb
40