using namespace grpc;
typedef struct _ServiceContext {
- GMainLoop *loop;
- GThread *thread;
std::unique_ptr<Server> server;
} ServiceContext;
-static gpointer
-_grpc_thread_func (gpointer data)
+static bool _service_app_create(void *data)
{
ServiceContext *ctx = (ServiceContext *)data;
std::string binding("0.0.0.0:50051");
ctx->server = std::move(builder.BuildAndStart());
ctx->server->Wait();
- return NULL;
-}
-
-static bool _service_app_create(void *data)
-{
- ServiceContext *ctx = (ServiceContext *)data;
-
- ctx->loop = g_main_loop_new ( NULL , FALSE );
- ctx->thread = g_thread_new("grpc_thread", _grpc_thread_func, ctx);
-
return true;
}
{
ServiceContext *ctx = (ServiceContext *)data;
ctx->server->Shutdown();
- g_main_loop_unref(ctx->loop);
- g_thread_join(ctx->thread);
}
static void _service_app_control(app_control_h app_control, void *data)