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.

runtime_context.h 2.3 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. /**
  2. * Copyright 2020 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_ENGINE_RUNTIME_CONTEXT_H_
  17. #define MINDSPORE_CCSRC_MINDDATA_DATASET_ENGINE_RUNTIME_CONTEXT_H_
  18. #include <memory>
  19. #include <utility>
  20. #include "minddata/dataset/core/client.h"
  21. #include "minddata/dataset/engine/consumers/tree_consumer.h"
  22. namespace mindspore::dataset {
  23. class TreeConsumer;
  24. /// Class that represents single runtime instance which can consume data from a data pipeline
  25. class RuntimeContext {
  26. public:
  27. /// Default constructor
  28. RuntimeContext() = default;
  29. /// Initialize the runtime, for now we just call the global init
  30. /// \return Status error code
  31. Status Init() const;
  32. /// Set the tree consumer
  33. /// \param tree_consumer to be assigned
  34. void AssignConsumer(std::shared_ptr<TreeConsumer> tree_consumer);
  35. /// Get the tree consumer
  36. /// \return Raw pointer to the tree consumer.
  37. TreeConsumer *GetConsumer();
  38. /// Method to terminate the runtime, this will not release the resources
  39. /// \return Status error code
  40. virtual Status Terminate() = 0;
  41. virtual ~RuntimeContext() = default;
  42. std::shared_ptr<TreeConsumer> tree_consumer_;
  43. };
  44. /// Class that represents C++ single runtime instance which can consume data from a data pipeline
  45. class NativeRuntimeContext : public RuntimeContext {
  46. public:
  47. /// Method to terminate the runtime, this will not release the resources
  48. /// \return Status error code
  49. Status Terminate() override;
  50. ~NativeRuntimeContext() override;
  51. private:
  52. /// Internal function to perform the termination
  53. /// \return Status error code
  54. Status TerminateImpl();
  55. };
  56. } // namespace mindspore::dataset
  57. #endif // MINDSPORE_CCSRC_MINDDATA_DATASET_ENGINE_RUNTIME_CONTEXT_H_