• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /**
2  * Copyright (c) 2023-2024 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  * http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #ifndef PANDA_RUNTIME_MEM_GC_WORKERS_GC_WORKERS_TASK_QUEUE_H
17 #define PANDA_RUNTIME_MEM_GC_WORKERS_GC_WORKERS_TASK_QUEUE_H
18 
19 #include "libpandabase/taskmanager/task.h"
20 #include "runtime/mem/gc/workers/gc_workers_task_pool.h"
21 
22 namespace ark::mem {
23 
24 /// @brief GC workers task pool based on common TaskManager (TaskQueue)
25 class GCWorkersTaskQueue final : public GCWorkersTaskPool {
26 public:
27     explicit GCWorkersTaskQueue(GC *gc);
28     NO_COPY_SEMANTIC(GCWorkersTaskQueue);
29     NO_MOVE_SEMANTIC(GCWorkersTaskQueue);
30     ~GCWorkersTaskQueue() final;
31 
32 private:
33     /**
34      * @brief Try to add new gc workers task to gc task queue
35      * @param task new gc workers task for gc task queue
36      * @return true if task successfully added to task queue, false - otherwise
37      */
38     bool TryAddTask(GCWorkersTask &&task) final;
39 
40     /**
41      * @brief Try to get gc task from gc task queue and
42      * run it in the current thread to help workers from task manager.
43      * Do nothing if couldn't get task
44      */
45     void RunInCurrentThread() final;
46 
47     /* GC task queue (TaskManager) specific variables */
48     static constexpr taskmanager::TaskProperties GC_TASK_PROPERTIES = {
49         taskmanager::TaskType::GC, taskmanager::VMType::STATIC_VM, taskmanager::TaskExecutionMode::FOREGROUND};
50 };
51 
52 }  // namespace ark::mem
53 
54 #endif  // PANDA_RUNTIME_MEM_GC_WORKERS_GC_WORKERS_TASK_QUEUE_H
55