/* * Copyright (c) 2024 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef OHOS_ARKCOMPILER_AOTCOMPILER_CLIENT_H #define OHOS_ARKCOMPILER_AOTCOMPILER_CLIENT_H #include #include #include #include #include #include "iaot_compiler_interface.h" #include "singleton.h" namespace OHOS::ArkCompiler { class AotCompilerClient { public: AotCompilerClient(); virtual ~AotCompilerClient() = default; static AotCompilerClient &GetInstance(); int32_t AotCompiler(const std::unordered_map &argsMap, std::vector &sigData); int32_t StopAotCompiler(); int32_t NeedReCompile(const std::string& oldVersion, bool& sigData); int32_t GetAOTVersion(std::string& sigData); void OnLoadSystemAbilitySuccess(const sptr &remoteObject); void OnLoadSystemAbilityFail(); void AotCompilerOnRemoteDied(const wptr &remoteObject); private: sptr GetAotCompilerProxy(); bool LoadAotCompilerService(); void SetAotCompiler(const sptr &remoteObject); sptr GetAotCompiler(); class AotCompilerDiedRecipient : public IRemoteObject::DeathRecipient { public: void OnRemoteDied(const wptr &remote) override; }; private: std::condition_variable loadSaCondition_; std::mutex loadSaMutex_; bool loadSaFinished_ {false}; std::mutex mutex_; sptr aotCompilerProxy_ = nullptr; sptr aotCompilerDiedRecipient_ = nullptr; DISALLOW_COPY_AND_MOVE(AotCompilerClient); }; } // namespace OHOS::ArkCompiler #endif // OHOS_ARKCOMPILER_AOTCOMPILER_CLIENT_H