1 | #include "duckdb/parallel/task.hpp" |
---|---|
2 | #include "duckdb/execution/executor.hpp" |
3 | #include "duckdb/main/client_context.hpp" |
4 | |
5 | namespace duckdb { |
6 | |
7 | ExecutorTask::ExecutorTask(Executor &executor_p) : executor(executor_p) { |
8 | } |
9 | |
10 | ExecutorTask::ExecutorTask(ClientContext &context) : ExecutorTask(Executor::Get(context)) { |
11 | } |
12 | |
13 | ExecutorTask::~ExecutorTask() { |
14 | } |
15 | |
16 | void ExecutorTask::Deschedule() { |
17 | auto this_ptr = shared_from_this(); |
18 | executor.AddToBeRescheduled(task&: this_ptr); |
19 | } |
20 | |
21 | void ExecutorTask::Reschedule() { |
22 | auto this_ptr = shared_from_this(); |
23 | executor.RescheduleTask(task&: this_ptr); |
24 | } |
25 | |
26 | TaskExecutionResult 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 |