• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /**
2  * Copyright 2021-2023 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_CORE_MINDRT_INCLUDE_MINDRT_HPP_H_
18 #define MINDSPORE_CORE_MINDRT_INCLUDE_MINDRT_HPP_H_
19 
20 #include <memory>
21 #include <string>
22 #include "mindrt/include/actor/actor.h"
23 
24 // brief provide an asynchronous programming framework as Actor model
25 namespace mindspore {
26 struct MindrtAddress {
27   std::string scheme;
28   std::string ip;
29   uint16_t port;
30 };
31 
32 // brief initialize the library
33 MS_CORE_API int Initialize(const std::string &tcpUrl, const std::string &tcpUrlAdv = "", const std::string &udpUrl = "",
34                            const std::string &udpUrlAdv = "", int threadCount = 0);
35 
36 // brief spawn a process to run an actor
37 MS_CORE_API AID Spawn(const ActorReference actor, bool sharedThread = true);
38 
39 // brief wait for the actor process to exit . It will be discarded
40 void Await(const ActorReference &actor);
41 
42 // brief get actor with aid
43 ActorReference GetActor(const AID &actor);
44 
45 // brief wait for the actor process to exit
46 void Await(const AID &actor);
47 
48 // brief  Terminate the actor  to exit
49 MS_CORE_API void Terminate(const AID &actor, const std::shared_ptr<ActorMgr> &actor_mgr = nullptr);
50 
51 // brief  Terminate all actors
52 void TerminateAll();
53 
54 // brief terminate the process. It will be discarded
55 void Finalize();
56 
57 // brief set the delegate of restful
58 void SetDelegate(const std::string &delegate);
59 
60 // set log pid of the process use mindrt
61 void SetLogPID(int pid);
62 
63 // get global mindrt address
64 const MindrtAddress &GetMindrtAddress();
65 
66 // get flag of http message format
67 int GetHttpKmsgFlag();
68 
69 // brief set flag of http message format
70 void SetHttpKmsgFlag(int flag);
71 }  // namespace mindspore
72 #endif
73