aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorGravatar Craig Tiller <craig.tiller@gmail.com>2015-02-26 19:14:33 -0800
committerGravatar Craig Tiller <craig.tiller@gmail.com>2015-02-26 19:14:33 -0800
commit47d03aae63b1fa801f9d16ce592ee64da78a98a0 (patch)
tree32c8b55041037701cedae642438d4d39ad087858 /src
parent289942fd06badd0cb896db1d4f258c7e4d441e8f (diff)
parentaa6babab1ce82d1ca1edaaf25dbf26bf67a353e4 (diff)
Merge pull request #860 from nicolasnoble/travis-c++
Travis c++
Diffstat (limited to 'src')
-rw-r--r--src/compiler/cpp_generator.cc8
-rw-r--r--src/compiler/python_generator.cc3
-rw-r--r--src/compiler/python_plugin.cc8
-rw-r--r--src/compiler/ruby_plugin.cc4
-rw-r--r--src/cpp/client/channel.h8
-rw-r--r--src/cpp/client/client_context.cc5
-rw-r--r--src/cpp/common/call.cc24
-rw-r--r--src/cpp/server/server.cc21
-rw-r--r--src/cpp/server/server_builder.cc2
-rw-r--r--src/cpp/server/server_context.cc29
-rw-r--r--src/cpp/server/thread_pool.cc2
-rw-r--r--src/cpp/server/thread_pool.h7
-rw-r--r--src/node/binding.gyp2
13 files changed, 81 insertions, 42 deletions
diff --git a/src/compiler/cpp_generator.cc b/src/compiler/cpp_generator.cc
index 891032343b..088fc6bc13 100644
--- a/src/compiler/cpp_generator.cc
+++ b/src/compiler/cpp_generator.cc
@@ -300,13 +300,13 @@ void PrintHeaderService(google::protobuf::io::Printer *printer,
(*vars)["Service"] = service->name();
printer->Print(*vars,
- "class $Service$ final {\n"
+ "class $Service$ GRPC_FINAL {\n"
" public:\n");
printer->Indent();
// Client side
printer->Print(
- "class Stub final : public ::grpc::InternalStub {\n"
+ "class Stub GRPC_FINAL : public ::grpc::InternalStub {\n"
" public:\n");
printer->Indent();
for (int i = 0; i < service->method_count(); ++i) {
@@ -331,7 +331,7 @@ void PrintHeaderService(google::protobuf::io::Printer *printer,
for (int i = 0; i < service->method_count(); ++i) {
PrintHeaderServerMethodSync(printer, service->method(i), vars);
}
- printer->Print("::grpc::RpcService* service() override final;\n");
+ printer->Print("::grpc::RpcService* service() GRPC_OVERRIDE GRPC_FINAL;\n");
printer->Outdent();
printer->Print(
" private:\n"
@@ -340,7 +340,7 @@ void PrintHeaderService(google::protobuf::io::Printer *printer,
// Server side - Asynchronous
printer->Print(
- "class AsyncService final : public ::grpc::AsynchronousService {\n"
+ "class AsyncService GRPC_FINAL : public ::grpc::AsynchronousService {\n"
" public:\n");
printer->Indent();
(*vars)["MethodCount"] = as_string(service->method_count());
diff --git a/src/compiler/python_generator.cc b/src/compiler/python_generator.cc
index 6aafc86be5..ae4d65df4c 100644
--- a/src/compiler/python_generator.cc
+++ b/src/compiler/python_generator.cc
@@ -232,7 +232,8 @@ bool GetModuleAndMessagePath(const Descriptor* type,
path_iter != message_path.rend(); ++path_iter) {
message_type += (*path_iter)->name() + ".";
}
- message_type.pop_back();
+ // no pop_back prior to C++11
+ message_type.resize(message_type.size() - 1);
*out = make_pair(module, message_type);
return true;
}
diff --git a/src/compiler/python_plugin.cc b/src/compiler/python_plugin.cc
index ed1e0494fb..0dd2c5b834 100644
--- a/src/compiler/python_plugin.cc
+++ b/src/compiler/python_plugin.cc
@@ -56,12 +56,10 @@ using std::strlen;
class PythonGrpcGenerator : public CodeGenerator {
public:
PythonGrpcGenerator() {}
- ~PythonGrpcGenerator() override {}
+ ~PythonGrpcGenerator() {}
- bool Generate(const FileDescriptor* file,
- const string& parameter,
- GeneratorContext* context,
- string* error) const override {
+ bool Generate(const FileDescriptor* file, const string& parameter,
+ GeneratorContext* context, string* error) const {
// Get output file name.
string file_name;
static const int proto_suffix_length = strlen(".proto");
diff --git a/src/compiler/ruby_plugin.cc b/src/compiler/ruby_plugin.cc
index 6580e5ab5b..4a6e9f7a5d 100644
--- a/src/compiler/ruby_plugin.cc
+++ b/src/compiler/ruby_plugin.cc
@@ -50,12 +50,12 @@
class RubyGrpcGenerator : public google::protobuf::compiler::CodeGenerator {
public:
RubyGrpcGenerator() {}
- ~RubyGrpcGenerator() override {}
+ ~RubyGrpcGenerator() {}
bool Generate(const google::protobuf::FileDescriptor *file,
const std::string &parameter,
google::protobuf::compiler::GeneratorContext *context,
- std::string *error) const override {
+ std::string *error) const {
std::string code = grpc_ruby_generator::GetServices(file);
if (code.size() == 0) {
return true; // don't generate a file if there are no services
diff --git a/src/cpp/client/channel.h b/src/cpp/client/channel.h
index 06f5a8ffdf..e3edcf73a5 100644
--- a/src/cpp/client/channel.h
+++ b/src/cpp/client/channel.h
@@ -49,17 +49,17 @@ class CompletionQueue;
class Credentials;
class StreamContextInterface;
-class Channel final : public ChannelInterface {
+class Channel GRPC_FINAL : public ChannelInterface {
public:
Channel(const grpc::string &target, const ChannelArguments &args);
Channel(const grpc::string &target, const std::unique_ptr<Credentials> &creds,
const ChannelArguments &args);
- ~Channel() override;
+ ~Channel() GRPC_OVERRIDE;
virtual Call CreateCall(const RpcMethod &method, ClientContext *context,
- CompletionQueue *cq) override;
- virtual void PerformOpsOnCall(CallOpBuffer *ops, Call *call) override;
+ CompletionQueue *cq) GRPC_OVERRIDE;
+ virtual void PerformOpsOnCall(CallOpBuffer *ops, Call *call) GRPC_OVERRIDE;
private:
const grpc::string target_;
diff --git a/src/cpp/client/client_context.cc b/src/cpp/client/client_context.cc
index 80cbdd93ac..9f99f7bcd5 100644
--- a/src/cpp/client/client_context.cc
+++ b/src/cpp/client/client_context.cc
@@ -41,7 +41,10 @@ using std::chrono::system_clock;
namespace grpc {
ClientContext::ClientContext()
- : call_(nullptr), cq_(nullptr), absolute_deadline_(gpr_inf_future) {}
+ : initial_metadata_received_(false),
+ call_(nullptr),
+ cq_(nullptr),
+ absolute_deadline_(gpr_inf_future) {}
ClientContext::~ClientContext() {
if (call_) {
diff --git a/src/cpp/common/call.cc b/src/cpp/common/call.cc
index e6a20a252d..f3a691114d 100644
--- a/src/cpp/common/call.cc
+++ b/src/cpp/common/call.cc
@@ -41,6 +41,30 @@
namespace grpc {
+CallOpBuffer::CallOpBuffer()
+ : return_tag_(this),
+ send_initial_metadata_(false),
+ initial_metadata_count_(0),
+ initial_metadata_(nullptr),
+ recv_initial_metadata_(nullptr),
+ recv_initial_metadata_arr_{0, 0, nullptr},
+ send_message_(nullptr),
+ send_message_buf_(nullptr),
+ recv_message_(nullptr),
+ recv_message_buf_(nullptr),
+ client_send_close_(false),
+ recv_trailing_metadata_(nullptr),
+ recv_status_(nullptr),
+ recv_trailing_metadata_arr_{0, 0, nullptr},
+ status_code_(GRPC_STATUS_OK),
+ status_details_(nullptr),
+ status_details_capacity_(0),
+ send_status_(nullptr),
+ trailing_metadata_count_(0),
+ trailing_metadata_(nullptr),
+ cancelled_buf_(0),
+ recv_closed_(nullptr) {}
+
void CallOpBuffer::Reset(void* next_return_tag) {
return_tag_ = next_return_tag;
diff --git a/src/cpp/server/server.cc b/src/cpp/server/server.cc
index 178fa1a716..97bf0f1a6e 100644
--- a/src/cpp/server/server.cc
+++ b/src/cpp/server/server.cc
@@ -49,11 +49,12 @@
namespace grpc {
-class Server::SyncRequest final : public CompletionQueueTag {
+class Server::SyncRequest GRPC_FINAL : public CompletionQueueTag {
public:
SyncRequest(RpcServiceMethod* method, void* tag)
: method_(method),
tag_(tag),
+ in_flight_(false),
has_request_payload_(method->method_type() == RpcMethod::NORMAL_RPC ||
method->method_type() ==
RpcMethod::SERVER_STREAMING),
@@ -85,14 +86,14 @@ class Server::SyncRequest final : public CompletionQueueTag {
this));
}
- bool FinalizeResult(void** tag, bool* status) override {
+ bool FinalizeResult(void** tag, bool* status) GRPC_OVERRIDE {
if (!*status) {
grpc_completion_queue_destroy(cq_);
}
return true;
}
- class CallData final {
+ class CallData GRPC_FINAL {
public:
explicit CallData(Server* server, SyncRequest* mrd)
: cq_(mrd->cq_),
@@ -159,7 +160,7 @@ class Server::SyncRequest final : public CompletionQueueTag {
private:
RpcServiceMethod* const method_;
void* const tag_;
- bool in_flight_ = false;
+ bool in_flight_;
const bool has_request_payload_;
const bool has_response_payload_;
grpc_call* call_;
@@ -294,7 +295,7 @@ void Server::PerformOpsOnCall(CallOpBuffer* buf, Call* call) {
grpc_call_start_batch(call->call(), ops, nops, buf));
}
-class Server::AsyncRequest final : public CompletionQueueTag {
+class Server::AsyncRequest GRPC_FINAL : public CompletionQueueTag {
public:
AsyncRequest(Server* server, void* registered_method, ServerContext* ctx,
::google::protobuf::Message* request,
@@ -305,7 +306,9 @@ class Server::AsyncRequest final : public CompletionQueueTag {
stream_(stream),
cq_(cq),
ctx_(ctx),
- server_(server) {
+ server_(server),
+ call_(nullptr),
+ payload_(nullptr) {
memset(&array_, 0, sizeof(array_));
grpc_server_request_registered_call(
server->server_, registered_method, &call_, &deadline_, &array_,
@@ -319,7 +322,7 @@ class Server::AsyncRequest final : public CompletionQueueTag {
grpc_metadata_array_destroy(&array_);
}
- bool FinalizeResult(void** tag, bool* status) override {
+ bool FinalizeResult(void** tag, bool* status) GRPC_OVERRIDE {
*tag = tag_;
if (*status && request_) {
if (payload_) {
@@ -354,10 +357,10 @@ class Server::AsyncRequest final : public CompletionQueueTag {
CompletionQueue* const cq_;
ServerContext* const ctx_;
Server* const server_;
- grpc_call* call_ = nullptr;
+ grpc_call* call_;
gpr_timespec deadline_;
grpc_metadata_array array_;
- grpc_byte_buffer* payload_ = nullptr;
+ grpc_byte_buffer* payload_;
};
void Server::RequestAsyncCall(void* registered_method, ServerContext* context,
diff --git a/src/cpp/server/server_builder.cc b/src/cpp/server/server_builder.cc
index 3c2093c363..ae60f3d8b6 100644
--- a/src/cpp/server/server_builder.cc
+++ b/src/cpp/server/server_builder.cc
@@ -41,7 +41,7 @@
namespace grpc {
-ServerBuilder::ServerBuilder() {}
+ServerBuilder::ServerBuilder() : thread_pool_(nullptr) {}
void ServerBuilder::RegisterService(SynchronousService* service) {
services_.push_back(service->service());
diff --git a/src/cpp/server/server_context.cc b/src/cpp/server/server_context.cc
index 1aa18bcac5..bb3c2d1405 100644
--- a/src/cpp/server/server_context.cc
+++ b/src/cpp/server/server_context.cc
@@ -44,10 +44,13 @@ namespace grpc {
// CompletionOp
-class ServerContext::CompletionOp final : public CallOpBuffer {
+class ServerContext::CompletionOp GRPC_FINAL : public CallOpBuffer {
public:
- CompletionOp();
- bool FinalizeResult(void** tag, bool* status) override;
+ // initial refs: one in the server context, one in the cq
+ CompletionOp() : refs_(2), finalized_(false), cancelled_(false) {
+ AddServerRecvClose(&cancelled_);
+ }
+ bool FinalizeResult(void** tag, bool* status) GRPC_OVERRIDE;
bool CheckCancelled(CompletionQueue* cq);
@@ -55,13 +58,11 @@ class ServerContext::CompletionOp final : public CallOpBuffer {
private:
std::mutex mu_;
- int refs_ = 2; // initial refs: one in the server context, one in the cq
- bool finalized_ = false;
- bool cancelled_ = false;
+ int refs_;
+ bool finalized_;
+ bool cancelled_;
};
-ServerContext::CompletionOp::CompletionOp() { AddServerRecvClose(&cancelled_); }
-
void ServerContext::CompletionOp::Unref() {
std::unique_lock<std::mutex> lock(mu_);
if (--refs_ == 0) {
@@ -90,11 +91,19 @@ bool ServerContext::CompletionOp::FinalizeResult(void** tag, bool* status) {
// ServerContext body
-ServerContext::ServerContext() {}
+ServerContext::ServerContext()
+ : completion_op_(nullptr),
+ call_(nullptr),
+ cq_(nullptr),
+ sent_initial_metadata_(false) {}
ServerContext::ServerContext(gpr_timespec deadline, grpc_metadata* metadata,
size_t metadata_count)
- : deadline_(Timespec2Timepoint(deadline)) {
+ : completion_op_(nullptr),
+ deadline_(Timespec2Timepoint(deadline)),
+ call_(nullptr),
+ cq_(nullptr),
+ sent_initial_metadata_(false) {
for (size_t i = 0; i < metadata_count; i++) {
client_metadata_.insert(std::make_pair(
grpc::string(metadata[i].key),
diff --git a/src/cpp/server/thread_pool.cc b/src/cpp/server/thread_pool.cc
index fa11ddd04c..5dc9bcf916 100644
--- a/src/cpp/server/thread_pool.cc
+++ b/src/cpp/server/thread_pool.cc
@@ -35,7 +35,7 @@
namespace grpc {
-ThreadPool::ThreadPool(int num_threads) {
+ThreadPool::ThreadPool(int num_threads) : shutdown_(false) {
for (int i = 0; i < num_threads; i++) {
threads_.push_back(std::thread([this]() {
for (;;) {
diff --git a/src/cpp/server/thread_pool.h b/src/cpp/server/thread_pool.h
index 283618f4b6..9c1df0b15b 100644
--- a/src/cpp/server/thread_pool.h
+++ b/src/cpp/server/thread_pool.h
@@ -34,6 +34,7 @@
#ifndef __GRPCPP_INTERNAL_SERVER_THREAD_POOL_H__
#define __GRPCPP_INTERNAL_SERVER_THREAD_POOL_H__
+#include <grpc++/config.h>
#include <grpc++/thread_pool_interface.h>
#include <condition_variable>
@@ -44,17 +45,17 @@
namespace grpc {
-class ThreadPool final : public ThreadPoolInterface {
+class ThreadPool GRPC_FINAL : public ThreadPoolInterface {
public:
explicit ThreadPool(int num_threads);
~ThreadPool();
- void ScheduleCallback(const std::function<void()> &callback) override;
+ void ScheduleCallback(const std::function<void()> &callback) GRPC_OVERRIDE;
private:
std::mutex mu_;
std::condition_variable cv_;
- bool shutdown_ = false;
+ bool shutdown_;
std::queue<std::function<void()>> callbacks_;
std::vector<std::thread> threads_;
};
diff --git a/src/node/binding.gyp b/src/node/binding.gyp
index 5c34be24ff..10afaf6962 100644
--- a/src/node/binding.gyp
+++ b/src/node/binding.gyp
@@ -10,7 +10,7 @@
"<!(node -e \"require('nan')\")"
],
'cflags': [
- '-std=c++11',
+ '-std=c++0x',
'-Wall',
'-pthread',
'-pedantic',