1 /** 2 * Copyright 2024 Huawei Technologies Co., Ltd 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 #ifndef MINDSPORE_CCSRC_PLUGIN_MINDIO_MINDIOADAPTER_H 18 #define MINDSPORE_CCSRC_PLUGIN_MINDIO_MINDIOADAPTER_H 19 20 #include <thread> 21 #include <functional> 22 #include <memory> 23 #include "utils/dlopen_macro.h" 24 25 namespace mindspore { 26 namespace mindio { 27 28 ORIGIN_METHOD(TTP_NotifyStartUpdatingOs, int, int64_t); 29 ORIGIN_METHOD(TTP_NotifyEndUpdatingOs, int, int64_t); 30 31 class MindIOAdapter { 32 public: 33 MindIOAdapter() = default; 34 virtual ~MindIOAdapter() = default; 35 MindIOAdapter(const MindIOAdapter &) = delete; 36 MindIOAdapter &operator=(const MindIOAdapter &) = delete; 37 38 void SetOsStateNotifyCallBack(const TTP_NotifyStartUpdatingOsFunObj &opStart, 39 const TTP_NotifyEndUpdatingOsFunObj &optEnd); 40 void NotifyStartUpdatingOs(); 41 void NotifyEndUpdatingOs(); 42 bool IsEnable(); 43 static std::shared_ptr<MindIOAdapter> GetInstance(); 44 static std::shared_ptr<MindIOAdapter> inst_mindio_; 45 46 private: 47 TTP_NotifyStartUpdatingOsFunObj _optStart = nullptr; 48 TTP_NotifyEndUpdatingOsFunObj _optEnd = nullptr; 49 bool isEnable; 50 }; 51 52 } // namespace mindio 53 } // namespace mindspore 54 #endif 55