gRPC Sync / Import

This commit is contained in:
Stanley Cheung 2018-03-07 12:24:55 -08:00
parent 0a717361ee
commit dfb2b08ce3
4 changed files with 10 additions and 12 deletions

View File

@ -26,27 +26,25 @@
#include "net/grpc/gateway/runtime/tag.h" #include "net/grpc/gateway/runtime/tag.h"
#include "third_party/grpc/include/grpc/grpc.h" #include "third_party/grpc/include/grpc/grpc.h"
#include "third_party/grpc/include/grpc/support/time.h" #include "third_party/grpc/include/grpc/support/time.h"
#include "third_party/grpc/src/core/lib/gpr/thd.h" #include "third_party/grpc/src/core/lib/gprpp/thd.h"
namespace grpc { namespace grpc {
namespace gateway { namespace gateway {
GrpcEventQueue::GrpcEventQueue() GrpcEventQueue::GrpcEventQueue()
: queue_(grpc_completion_queue_create_for_next(nullptr)), thread_id_(0) {} : queue_(grpc_completion_queue_create_for_next(nullptr)),
thread_("grpc_event_queue", ExecuteEventLoop, this) {}
GrpcEventQueue::~GrpcEventQueue() {} GrpcEventQueue::~GrpcEventQueue() {}
void GrpcEventQueue::Start() { void GrpcEventQueue::Start() {
gpr_thd_options thread_options = gpr_thd_options_default(); thread_.Start();
gpr_thd_options_set_joinable(&thread_options); INFO("GRPC event thread started");
int ret = gpr_thd_new(&thread_id_, "grpc_event_queue", ExecuteEventLoop, this,
&thread_options);
INFO("GRPC event thread started: %d", ret);
} }
void GrpcEventQueue::Stop() { void GrpcEventQueue::Stop() {
grpc_completion_queue_shutdown(queue_); grpc_completion_queue_shutdown(queue_);
gpr_thd_join(thread_id_); thread_.Join();
grpc_completion_queue_destroy(queue_); grpc_completion_queue_destroy(queue_);
} }

View File

@ -20,7 +20,7 @@
#define NET_GRPC_GATEWAY_RUNTIME_GRPC_EVENT_QUEUE_H_ #define NET_GRPC_GATEWAY_RUNTIME_GRPC_EVENT_QUEUE_H_
#include "third_party/grpc/include/grpc/grpc.h" #include "third_party/grpc/include/grpc/grpc.h"
#include "third_party/grpc/include/grpc/support/thd_id.h" #include "third_party/grpc/src/core/lib/gprpp/thd.h"
namespace grpc { namespace grpc {
namespace gateway { namespace gateway {
@ -49,7 +49,7 @@ class GrpcEventQueue {
grpc_completion_queue* queue_; grpc_completion_queue* queue_;
gpr_thd_id thread_id_; grpc_core::Thread thread_;
}; };
} // namespace gateway } // namespace gateway
} // namespace grpc } // namespace grpc

View File

@ -17,4 +17,4 @@ cd "$(dirname "$0")"/..
git submodule update --init git submodule update --init
cd third_party/closure-library && git checkout tags/v20171112 -f && cd ../.. cd third_party/closure-library && git checkout tags/v20171112 -f && cd ../..
cd third_party/openssl && git checkout tags/OpenSSL_1_0_2h -f && cd ../.. cd third_party/openssl && git checkout tags/OpenSSL_1_0_2h -f && cd ../..
cd third_party/grpc && git checkout 8224c45 -f && git submodule update --init && cd ../.. cd third_party/grpc && git checkout 8b875ac -f && git submodule update --init && cd ../..

2
third_party/grpc vendored

@ -1 +1 @@
Subproject commit 8224c45866c6a2cfa29ede0c91a6ae9f40572658 Subproject commit 8b875ac9413978370c4eafa2e2fb6a3b2f054297