• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 
2 /*
3  * Copyright (c) 2024 Huawei Device Co., Ltd.
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 
17 #ifndef MODULE_UPDATE_TASK_H
18 #define MODULE_UPDATE_TASK_H
19 
20 #include "module_ipc_helper.h"
21 #include "singleton.h"
22 #include "thread_pool.h"
23 
24 namespace OHOS {
25 namespace SysInstaller {
26 class ModuleUpdateTask {
27 public:
28     ModuleUpdateTask(const std::string &hmpName);
29     void SetHmpName(const std::string &hmpName);
30     std::string &GetHmpName();
31 private:
32     std::string hmpName_;
33 };
34 
35 class ModuleUpdateTaskManager : public OHOS::Singleton<ModuleUpdateTaskManager> {
36     friend class OHOS::Singleton<ModuleUpdateTaskManager>;
37 public:
~ModuleUpdateTaskManager()38     ~ModuleUpdateTaskManager() override {}
39     void SetTaskResult(bool result);
40     bool GetTaskResult();
41     bool AddTask(const std::string &hmpName);
42     void ClearTask();
43     void Start();
44     void Stop();
45     size_t GetCurTaskNum();
46 
47 private:
48     static constexpr size_t MAX_TASK_NUM = 100; // 100 is max task number
ModuleUpdateTaskManager()49     ModuleUpdateTaskManager() {}
50     ModuleUpdateTaskManager(const ModuleUpdateTaskManager&) = delete;
51     OHOS::ThreadPool pool_;
52     bool taskResult_ = true;
53     size_t taskNum_;
54 };
55 } // SysInstaller
56 } // namespace OHOS
57 #endif // SYS_INSTALLER_MODULE_UPDATE_H