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 Oct 2020 |
18 | * \brief |
19 | */ |
20 | |
21 | #pragma once |
22 | |
23 | #include "task.h" |
24 | |
25 | namespace proxima { |
26 | namespace be { |
27 | namespace query { |
28 | |
29 | //! Predefine class |
30 | class TaskQueue; |
31 | //! Alias for TaskQueue |
32 | using TaskQueuePtr = std::shared_ptr<TaskQueue>; |
33 | |
34 | /*! |
35 | * TaskQueue Interface, |
36 | */ |
37 | class TaskQueue { |
38 | public: |
39 | /*! |
40 | * Queue status flag |
41 | */ |
42 | enum Status { |
43 | INITIALIZED, |
44 | STARTED, |
45 | STOPPED, |
46 | JOINED, |
47 | }; |
48 | |
49 | public: |
50 | //! Destructor |
51 | virtual ~TaskQueue() = default; |
52 | |
53 | public: |
54 | //! Start task queue, return value 0 for success, otherwise failed |
55 | virtual int start() = 0; |
56 | |
57 | //! Stop task queue, return value 0 for success, otherwise failed |
58 | virtual int stop() = 0; |
59 | |
60 | //! Join task queue, return value 0 for success, otherwise failed |
61 | virtual int join() = 0; |
62 | |
63 | //! Put the task in queue |
64 | //! @return, 0: succeed, mark status of task as Scheduled |
65 | //! other: failed |
66 | virtual int put(const TaskPtr &task) = 0; |
67 | |
68 | //! Retrieve start flags |
69 | virtual bool started() const = 0; |
70 | }; |
71 | |
72 | |
73 | } // namespace query |
74 | } // namespace be |
75 | } // namespace proxima |
76 | |