1 /*
2  * Copyright (c) 2023 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 #include "core/common/task_runners.h"
17 
18 namespace OHOS::Ace {
TaskRunners(std::string label,RefPtr<TaskRunnerAdapter> & platform,RefPtr<TaskRunnerAdapter> & gpu,RefPtr<TaskRunnerAdapter> & ui,RefPtr<TaskRunnerAdapter> & io)19 TaskRunners::TaskRunners(std::string label, RefPtr<TaskRunnerAdapter>& platform, RefPtr<TaskRunnerAdapter>& gpu,
20     RefPtr<TaskRunnerAdapter>& ui, RefPtr<TaskRunnerAdapter>& io)
21     : label_(std::move(label)), platform_(std::move(platform)), gpu_(std::move(gpu)), ui_(std::move(ui)),
22       io_(std::move(io))
23 {}
24 
GetPlatformTaskRunner() const25 RefPtr<TaskRunnerAdapter> TaskRunners::GetPlatformTaskRunner() const
26 {
27     return platform_;
28 }
29 
GetUITaskRunner() const30 RefPtr<TaskRunnerAdapter> TaskRunners::GetUITaskRunner() const
31 {
32     return ui_;
33 }
34 
GetIOTaskRunner() const35 RefPtr<TaskRunnerAdapter> TaskRunners::GetIOTaskRunner() const
36 {
37     return io_;
38 }
39 
GetGPUTaskRunner() const40 RefPtr<TaskRunnerAdapter> TaskRunners::GetGPUTaskRunner() const
41 {
42     return gpu_;
43 }
44 
GetLabel() const45 const std::string& TaskRunners::GetLabel() const
46 {
47     return label_;
48 }
49 
IsValid() const50 bool TaskRunners::IsValid() const
51 {
52     return platform_ && gpu_ && ui_ && io_;
53 }
54 } // namespace OHOS::Ace
55