• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /**
2  * Copyright (c) 2023-2025 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_G1_UPDATE_REMSET_TASK_QUEUE_H
17 #define PANDA_RUNTIME_MEM_GC_G1_UPDATE_REMSET_TASK_QUEUE_H
18 
19 #include "runtime/mem/gc/g1/update_remset_worker.h"
20 
21 #include "libpandabase/taskmanager/task.h"
22 #include "libpandabase/taskmanager/utils/wait_list.h"
23 
24 namespace ark::mem {
25 
26 template <class LanguageConfig>
27 class UpdateRemsetTaskQueue final : public UpdateRemsetWorker<LanguageConfig> {
28 public:
29     UpdateRemsetTaskQueue(G1GC<LanguageConfig> *gc, GCG1BarrierSet::ThreadLocalCardQueues *queue,
30                           os::memory::Mutex *queueLock, size_t regionSize, bool updateConcurrent,
31                           size_t minConcurrentCardsToProcess, size_t hotCardsProcessingFrequency);
32     NO_COPY_SEMANTIC(UpdateRemsetTaskQueue);
33     NO_MOVE_SEMANTIC(UpdateRemsetTaskQueue);
34     ~UpdateRemsetTaskQueue() final;
35 
36 private:
37     void CreateWorkerImpl() final;
38 
39     void DestroyWorkerImpl() final;
40 
41     void ContinueProcessCards() REQUIRES(this->updateRemsetLock_) final;
42 
43     /**
44      * @brief Add a new process cards task in task manager if such task does not exist. Else if taskRunnerWaiterId_ is
45      * valid, signal wait list to execute task.
46      */
47     void StartProcessCards() REQUIRES(this->updateRemsetLock_);
48 
49     /// @brief Add a new process cards task in task manager wait list with timeout.
50     void AddToWaitListWithTimeout() REQUIRES(this->updateRemsetLock_);
51 
52     /// @brief Add a new process cards task in task manager wait list. @returns id of waiter in wait list
53     void AddToWaitList() REQUIRES(this->updateRemsetLock_);
54 
55     bool hasTaskInTaskmanager_ GUARDED_BY(this->updateRemsetLock_) {false};
56 
57     std::function<void()> taskRunner_ {nullptr};
58 
59     taskmanager::WaiterId taskRunnerWaiterId_ GUARDED_BY(this->updateRemsetLock_) {taskmanager::INVALID_WAITER_ID};
60 };
61 
62 }  // namespace ark::mem
63 
64 #endif  // PANDA_RUNTIME_MEM_GC_G1_UPDATE_REMSET_TASK_QUEUE_H
65