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 #include "eu/sexecute_unit.h" 18 19 #include "internal_inc/config.h" 20 #include "eu/scpuworker_manager.h" 21 #include "eu/co_routine_factory.h" 22 23 namespace ffrt { SExecuteUnit()24SExecuteUnit::SExecuteUnit() 25 { 26 ffrt::CoRoutineInstance(CoStackAttr::Instance()->size); 27 auto create = [&](const DevType dev) { 28 std::unique_ptr<WorkerManager> manager; 29 switch (dev) { 30 case DevType::CPU: 31 manager = std::unique_ptr<WorkerManager>(new (std::nothrow) SCPUWorkerManager()); 32 break; 33 default: 34 break; 35 } 36 37 if (!manager) { 38 FFRT_LOGE("create workerManager fail, devType %d", static_cast<size_t>(dev)); 39 return; 40 } 41 42 wManager[static_cast<size_t>(dev)] = std::move(manager); 43 }; 44 45 for (size_t dev = 0; dev < static_cast<size_t>(DevType::DEVMAX); ++dev) { 46 create(static_cast<DevType>(dev)); 47 } 48 } 49 } // namespace ffrt 50