1/**
2 * Copyright 2021 Alibaba, Inc. and its affiliates. All Rights Reserved.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 *
16 * \author guonix
17 * \date Nov 2020
18 * \brief
19 */
20
21#pragma once
22
23#include "executor.h"
24#include "scheduler.h"
25
26namespace proxima {
27namespace be {
28namespace query {
29
30/*!
31 * Parallel Executor
32 */
33class ParallelExecutor : public Executor {
34 public:
35 //! Constructor
36 explicit ParallelExecutor(SchedulerPtr scheduler);
37
38 //! Destructor
39 ~ParallelExecutor() override;
40
41 public:
42 //! Execute one task
43 int execute_task(const TaskPtr &task) override;
44
45 //! Execute tasks
46 int execute_tasks(const TaskPtrList &tasks) override;
47
48 private:
49 //! Wait all task finish and collect execution status,
50 //! return value 0 for success, otherwise failed
51 int wait_finish(const TaskPtrList &tasks);
52
53 private:
54 //! Scheduler handle
55 SchedulerPtr scheduler_{nullptr};
56};
57
58
59} // namespace query
60} // namespace be
61} // namespace proxima
62