You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

intrp_service.h 1.9 kB

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