1 /* 2 * Copyright (c) 2021 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/container.h" 17 18 #include "core/common/ace_engine.h" 19 #include "core/common/container_scope.h" 20 21 namespace OHOS::Ace { 22 CurrentId()23int32_t Container::CurrentId() 24 { 25 return ContainerScope::CurrentId(); 26 } 27 Current()28RefPtr<Container> Container::Current() 29 { 30 return AceEngine::Get().GetContainer(ContainerScope::CurrentId()); 31 } 32 CurrentTaskExecutor()33RefPtr<TaskExecutor> Container::CurrentTaskExecutor() 34 { 35 auto curContainer = Current(); 36 if (curContainer) { 37 return curContainer->GetTaskExecutor(); 38 } 39 return nullptr; 40 } 41 UpdateCurrent(int32_t id)42void Container::UpdateCurrent(int32_t id) 43 { 44 ContainerScope::UpdateCurrent(id); 45 } 46 47 } // namespace OHOS::Ace