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 #ifndef UTIL_FFRTFACADE_HPP 16 #define UTIL_FFRTFACADE_HPP 17 #include "util/slab.h" 18 #include "tm/cpu_task.h" 19 #include "sched/scheduler.h" 20 #include "eu/execute_unit.h" 21 #include "dm/dependence_manager.h" 22 namespace ffrt { 23 24 class FFRTFacade { 25 public: GetEUInstance()26 static inline ExecuteUnit& GetEUInstance() 27 { 28 return Instance().GetEUInstanceImpl(); 29 } 30 GetDMInstance()31 static inline DependenceManager& GetDMInstance() 32 { 33 return Instance().GetDMInstanceImpl(); 34 } 35 36 private: FFRTFacade()37 FFRTFacade() 38 { 39 DependenceManager::Instance(); 40 } 41 Instance()42 static FFRTFacade& Instance() 43 { 44 static FFRTFacade facade; 45 return facade; 46 } 47 GetEUInstanceImpl()48 inline ExecuteUnit& GetEUInstanceImpl() 49 { 50 return ExecuteUnit::Instance(); 51 } 52 GetDMInstanceImpl()53 inline DependenceManager& GetDMInstanceImpl() 54 { 55 return DependenceManager::Instance(); 56 } 57 }; 58 59 } // namespace FFRT 60 #endif