1 /** 2 * Copyright 2019 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 #ifndef MINDSPORE_CCSRC_MINDDATA_DATASET_UTIL_INTRP_SERVICE_H_ 17 #define MINDSPORE_CCSRC_MINDDATA_DATASET_UTIL_INTRP_SERVICE_H_ 18 19 #include <map> 20 #include <memory> 21 #include <mutex> 22 #include <string> 23 #include <utility> 24 #include "minddata/dataset/util/allocator.h" 25 #include "minddata/dataset/util/intrp_resource.h" 26 #include "minddata/dataset/util/log_adapter.h" 27 #include "minddata/dataset/util/service.h" 28 #include "minddata/dataset/util/services.h" 29 #include "minddata/dataset/util/status.h" 30 31 namespace mindspore { 32 namespace dataset { 33 using SvcAllocator = Allocator<std::pair<const std::string, IntrpResource *>>; 34 35 class IntrpService : public Service { 36 public: 37 IntrpService(); 38 39 ~IntrpService() noexcept override; 40 41 IntrpService(const IntrpService &) = delete; 42 43 IntrpService &operator=(const IntrpService &) = delete; 44 45 Status Register(const std::string &name, IntrpResource *res); 46 47 Status Deregister(const std::string &name) noexcept; 48 49 void InterruptAll() noexcept; 50 DoServiceStart()51 Status DoServiceStart() override { return Status::OK(); } 52 DoServiceStop()53 Status DoServiceStop() override { return Status::OK(); } 54 55 private: 56 int high_water_mark_; 57 std::mutex mutex_; 58 std::map<std::string, IntrpResource *> all_intrp_resources_; 59 }; 60 } // namespace dataset 61 } // namespace mindspore 62 #endif // MINDSPORE_CCSRC_MINDDATA_DATASET_UTIL_INTRP_SERVICE_H_ 63