static */
| 32 | namespace tensorflow { |
| 33 | |
| 34 | /* static */ Status CGrpcServer::Create( |
| 35 | const ServerDef& server_def, |
| 36 | void* (*init_function)(const TF_GrpcServer*, TF_Status*), |
| 37 | void (*start_function)(const TF_GrpcServer*, void*, TF_Status*), |
| 38 | void (*stop_function)(const TF_GrpcServer*, void*, TF_Status*), |
| 39 | void (*join_function)(const TF_GrpcServer*, void*, TF_Status*), |
| 40 | void (*delete_function)(void*), |
| 41 | TF_RemoteRendezvousBuilder* rendezvous_builder, |
| 42 | std::unique_ptr<ServerInterface>* out_server) { |
| 43 | auto* grpc_server = new CGrpcServer(server_def, start_function, stop_function, |
| 44 | join_function, delete_function); |
| 45 | |
| 46 | GrpcServerOptions options; |
| 47 | options.rendezvous_mgr_func = [rendezvous_builder](const WorkerEnv* env) { |
| 48 | return new CRendezvousMgr(env, rendezvous_builder); |
| 49 | }; |
| 50 | TF_RETURN_IF_ERROR(grpc_server->Init(options)); |
| 51 | TF_Status* tf_status = TF_NewStatus(); |
| 52 | grpc_server->SetContext(init_function( |
| 53 | reinterpret_cast<const TF_GrpcServer*>(grpc_server), tf_status)); |
| 54 | TF_RETURN_IF_ERROR(tf_status->status); |
| 55 | TF_DeleteStatus(tf_status); |
| 56 | |
| 57 | out_server->reset(grpc_server); |
| 58 | return Status::OK(); |
| 59 | } |
| 60 | |
| 61 | Status CGrpcServer::Start() { |
| 62 | Status status = GrpcServer::Start(); |