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 "eu/execute_unit.h"
17
18 #include "internal_inc/config.h"
19 #include "eu/cpuworker_manager.h"
20 #include "util/singleton_register.h"
21
22 namespace ffrt {
ExecuteUnit()23 ExecuteUnit::ExecuteUnit()
24 {
25 }
26
Instance()27 ExecuteUnit& ExecuteUnit::Instance()
28 {
29 return SingletonRegister<ExecuteUnit>::Instance();
30 }
31
RegistInsCb(SingleInsCB<ExecuteUnit>::Instance && cb)32 void ExecuteUnit::RegistInsCb(SingleInsCB<ExecuteUnit>::Instance &&cb)
33 {
34 SingletonRegister<ExecuteUnit>::RegistInsCb(std::move(cb));
35 }
36
BindTG(const DevType dev,QoS & qos)37 ThreadGroup* ExecuteUnit::BindTG(const DevType dev, QoS& qos)
38 {
39 return wManager[static_cast<size_t>(dev)]->JoinTG(qos);
40 }
41
BindWG(const DevType dev,QoS & qos)42 void ExecuteUnit::BindWG(const DevType dev, QoS& qos)
43 {
44 return wManager[static_cast<size_t>(dev)]->JoinRtg(qos);
45 }
46
UnbindTG(const DevType dev,QoS & qos)47 void ExecuteUnit::UnbindTG(const DevType dev, QoS& qos)
48 {
49 wManager[static_cast<size_t>(dev)]->LeaveTG(qos);
50 }
51 } // namespace ffrt
52