aboutsummaryrefslogtreecommitdiffhomepage
path: root/include/grpc++
diff options
context:
space:
mode:
authorGravatar Mark D. Roth <roth@google.com>2016-09-16 07:35:37 -0700
committerGravatar Mark D. Roth <roth@google.com>2016-09-16 07:35:37 -0700
commitabf03aed93e95c934143bcb986add21ed8ca239f (patch)
tree4e290c0e0046ae8fd13a2c2fab46f5e69ab6dbf0 /include/grpc++
parent311e7badb80cceac466b57f03094844a2c289cf4 (diff)
parentd2f7268bc702d0bf2083b9dedb2ec07544b83dd2 (diff)
Merge remote-tracking branch 'upstream/master' into max_send_size_filter
Diffstat (limited to 'include/grpc++')
-rw-r--r--include/grpc++/impl/codegen/async_unary_call.h1
-rw-r--r--include/grpc++/impl/codegen/call.h4
-rw-r--r--include/grpc++/impl/codegen/client_context.h2
-rw-r--r--include/grpc++/impl/codegen/completion_queue.h3
-rw-r--r--include/grpc++/impl/codegen/core_codegen.h12
-rw-r--r--include/grpc++/impl/codegen/core_codegen_interface.h18
-rw-r--r--include/grpc++/impl/codegen/grpc_library.h1
-rw-r--r--include/grpc++/impl/codegen/proto_utils.h3
-rw-r--r--include/grpc++/impl/codegen/rpc_service_method.h5
-rw-r--r--include/grpc++/impl/codegen/server_context.h1
-rw-r--r--include/grpc++/impl/codegen/server_interface.h7
-rw-r--r--include/grpc++/impl/codegen/status_helper.h47
-rw-r--r--include/grpc++/impl/codegen/sync_no_cxx11.h28
-rw-r--r--include/grpc++/impl/codegen/sync_stream.h1
-rw-r--r--include/grpc++/impl/codegen/thrift_serializer.h4
-rw-r--r--include/grpc++/impl/codegen/thrift_utils.h2
-rw-r--r--include/grpc++/impl/codegen/time.h4
17 files changed, 111 insertions, 32 deletions
diff --git a/include/grpc++/impl/codegen/async_unary_call.h b/include/grpc++/impl/codegen/async_unary_call.h
index 5ceab73cea..87c94d6507 100644
--- a/include/grpc++/impl/codegen/async_unary_call.h
+++ b/include/grpc++/impl/codegen/async_unary_call.h
@@ -40,7 +40,6 @@
#include <grpc++/impl/codegen/server_context.h>
#include <grpc++/impl/codegen/service_type.h>
#include <grpc++/impl/codegen/status.h>
-#include <grpc/impl/codegen/log.h>
namespace grpc {
diff --git a/include/grpc++/impl/codegen/call.h b/include/grpc++/impl/codegen/call.h
index f113aa0e45..e211373e7d 100644
--- a/include/grpc++/impl/codegen/call.h
+++ b/include/grpc++/impl/codegen/call.h
@@ -46,9 +46,9 @@
#include <grpc++/impl/codegen/core_codegen_interface.h>
#include <grpc++/impl/codegen/serialization_traits.h>
#include <grpc++/impl/codegen/status.h>
+#include <grpc++/impl/codegen/status_helper.h>
#include <grpc++/impl/codegen/string_ref.h>
-#include <grpc/impl/codegen/alloc.h>
#include <grpc/impl/codegen/compression_types.h>
#include <grpc/impl/codegen/grpc_types.h>
@@ -438,7 +438,7 @@ class CallOpServerSendStatus {
trailing_metadata_count_ = trailing_metadata.size();
trailing_metadata_ = FillMetadataArray(trailing_metadata);
send_status_available_ = true;
- send_status_code_ = static_cast<grpc_status_code>(status.error_code());
+ send_status_code_ = static_cast<grpc_status_code>(GetCanonicalCode(status));
send_status_details_ = status.error_message();
}
diff --git a/include/grpc++/impl/codegen/client_context.h b/include/grpc++/impl/codegen/client_context.h
index 9fecb5043e..387d807c4b 100644
--- a/include/grpc++/impl/codegen/client_context.h
+++ b/include/grpc++/impl/codegen/client_context.h
@@ -62,9 +62,7 @@
#include <grpc++/impl/codegen/sync.h>
#include <grpc++/impl/codegen/time.h>
#include <grpc/impl/codegen/compression_types.h>
-#include <grpc/impl/codegen/log.h>
#include <grpc/impl/codegen/propagation_bits.h>
-#include <grpc/impl/codegen/time.h>
struct census_context;
struct grpc_call;
diff --git a/include/grpc++/impl/codegen/completion_queue.h b/include/grpc++/impl/codegen/completion_queue.h
index 78bc5ca481..29bc97fdf7 100644
--- a/include/grpc++/impl/codegen/completion_queue.h
+++ b/include/grpc++/impl/codegen/completion_queue.h
@@ -52,7 +52,6 @@
#include <grpc++/impl/codegen/grpc_library.h>
#include <grpc++/impl/codegen/status.h>
#include <grpc++/impl/codegen/time.h>
-#include <grpc/impl/codegen/time.h>
struct grpc_completion_queue;
@@ -219,7 +218,7 @@ class CompletionQueue : private GrpcLibraryCodegen {
/// Performs a single polling pluck on \a tag.
/// \warning Must not be mixed with calls to \a Next.
void TryPluck(CompletionQueueTag* tag) {
- auto deadline = gpr_time_0(GPR_CLOCK_REALTIME);
+ auto deadline = g_core_codegen_interface->gpr_time_0(GPR_CLOCK_REALTIME);
auto ev = g_core_codegen_interface->grpc_completion_queue_pluck(
cq_, tag, deadline, nullptr);
if (ev.type == GRPC_QUEUE_TIMEOUT) return;
diff --git a/include/grpc++/impl/codegen/core_codegen.h b/include/grpc++/impl/codegen/core_codegen.h
index 2586b94504..0ce009e69d 100644
--- a/include/grpc++/impl/codegen/core_codegen.h
+++ b/include/grpc++/impl/codegen/core_codegen.h
@@ -55,6 +55,17 @@ class CoreCodegen : public CoreCodegenInterface {
void* gpr_malloc(size_t size) GRPC_OVERRIDE;
void gpr_free(void* p) GRPC_OVERRIDE;
+ void gpr_mu_init(gpr_mu* mu) GRPC_OVERRIDE;
+ void gpr_mu_destroy(gpr_mu* mu) GRPC_OVERRIDE;
+ void gpr_mu_lock(gpr_mu* mu) GRPC_OVERRIDE;
+ void gpr_mu_unlock(gpr_mu* mu) GRPC_OVERRIDE;
+ void gpr_cv_init(gpr_cv* cv) GRPC_OVERRIDE;
+ void gpr_cv_destroy(gpr_cv* cv) GRPC_OVERRIDE;
+ int gpr_cv_wait(gpr_cv* cv, gpr_mu* mu,
+ gpr_timespec abs_deadline) GRPC_OVERRIDE;
+ void gpr_cv_signal(gpr_cv* cv) GRPC_OVERRIDE;
+ void gpr_cv_broadcast(gpr_cv* cv) GRPC_OVERRIDE;
+
void grpc_byte_buffer_destroy(grpc_byte_buffer* bb) GRPC_OVERRIDE;
int grpc_byte_buffer_reader_init(grpc_byte_buffer_reader* reader,
@@ -78,6 +89,7 @@ class CoreCodegen : public CoreCodegenInterface {
void grpc_metadata_array_destroy(grpc_metadata_array* array) GRPC_OVERRIDE;
gpr_timespec gpr_inf_future(gpr_clock_type type) GRPC_OVERRIDE;
+ gpr_timespec gpr_time_0(gpr_clock_type type) GRPC_OVERRIDE;
virtual const Status& ok() GRPC_OVERRIDE;
virtual const Status& cancelled() GRPC_OVERRIDE;
diff --git a/include/grpc++/impl/codegen/core_codegen_interface.h b/include/grpc++/impl/codegen/core_codegen_interface.h
index f9a8f9b980..68851f15c6 100644
--- a/include/grpc++/impl/codegen/core_codegen_interface.h
+++ b/include/grpc++/impl/codegen/core_codegen_interface.h
@@ -36,7 +36,13 @@
#include <grpc++/impl/codegen/config.h>
#include <grpc++/impl/codegen/status.h>
+#include <grpc/impl/codegen/byte_buffer_reader.h>
#include <grpc/impl/codegen/grpc_types.h>
+#include <grpc/impl/codegen/sync.h>
+
+extern "C" {
+struct grpc_byte_buffer;
+}
namespace grpc {
@@ -63,6 +69,17 @@ class CoreCodegenInterface {
virtual void* gpr_malloc(size_t size) = 0;
virtual void gpr_free(void* p) = 0;
+ virtual void gpr_mu_init(gpr_mu* mu) = 0;
+ virtual void gpr_mu_destroy(gpr_mu* mu) = 0;
+ virtual void gpr_mu_lock(gpr_mu* mu) = 0;
+ virtual void gpr_mu_unlock(gpr_mu* mu) = 0;
+ virtual void gpr_cv_init(gpr_cv* cv) = 0;
+ virtual void gpr_cv_destroy(gpr_cv* cv) = 0;
+ virtual int gpr_cv_wait(gpr_cv* cv, gpr_mu* mu,
+ gpr_timespec abs_deadline) = 0;
+ virtual void gpr_cv_signal(gpr_cv* cv) = 0;
+ virtual void gpr_cv_broadcast(gpr_cv* cv) = 0;
+
virtual void grpc_byte_buffer_destroy(grpc_byte_buffer* bb) = 0;
virtual int grpc_byte_buffer_reader_init(grpc_byte_buffer_reader* reader,
@@ -89,6 +106,7 @@ class CoreCodegenInterface {
virtual const Status& cancelled() = 0;
virtual gpr_timespec gpr_inf_future(gpr_clock_type type) = 0;
+ virtual gpr_timespec gpr_time_0(gpr_clock_type type) = 0;
};
extern CoreCodegenInterface* g_core_codegen_interface;
diff --git a/include/grpc++/impl/codegen/grpc_library.h b/include/grpc++/impl/codegen/grpc_library.h
index 3cdc6f3f7c..2b11aff214 100644
--- a/include/grpc++/impl/codegen/grpc_library.h
+++ b/include/grpc++/impl/codegen/grpc_library.h
@@ -35,7 +35,6 @@
#define GRPCXX_IMPL_CODEGEN_GRPC_LIBRARY_H
#include <grpc++/impl/codegen/core_codegen_interface.h>
-#include <grpc/impl/codegen/log.h>
namespace grpc {
diff --git a/include/grpc++/impl/codegen/proto_utils.h b/include/grpc++/impl/codegen/proto_utils.h
index e91e0b79fa..6f4786b87b 100644
--- a/include/grpc++/impl/codegen/proto_utils.h
+++ b/include/grpc++/impl/codegen/proto_utils.h
@@ -40,9 +40,8 @@
#include <grpc++/impl/codegen/core_codegen_interface.h>
#include <grpc++/impl/codegen/serialization_traits.h>
#include <grpc++/impl/codegen/status.h>
-#include <grpc/impl/codegen/byte_buffer.h>
#include <grpc/impl/codegen/byte_buffer_reader.h>
-#include <grpc/impl/codegen/log.h>
+#include <grpc/impl/codegen/grpc_types.h>
#include <grpc/impl/codegen/slice.h>
namespace grpc {
diff --git a/include/grpc++/impl/codegen/rpc_service_method.h b/include/grpc++/impl/codegen/rpc_service_method.h
index 6fdc571dee..78c54e3771 100644
--- a/include/grpc++/impl/codegen/rpc_service_method.h
+++ b/include/grpc++/impl/codegen/rpc_service_method.h
@@ -43,7 +43,10 @@
#include <grpc++/impl/codegen/config.h>
#include <grpc++/impl/codegen/rpc_method.h>
#include <grpc++/impl/codegen/status.h>
-#include <grpc/impl/codegen/byte_buffer.h>
+
+extern "C" {
+struct grpc_byte_buffer;
+}
namespace grpc {
class ServerContext;
diff --git a/include/grpc++/impl/codegen/server_context.h b/include/grpc++/impl/codegen/server_context.h
index 379c9f7cf8..bce8d2c2f8 100644
--- a/include/grpc++/impl/codegen/server_context.h
+++ b/include/grpc++/impl/codegen/server_context.h
@@ -43,7 +43,6 @@
#include <grpc++/impl/codegen/string_ref.h>
#include <grpc++/impl/codegen/time.h>
#include <grpc/impl/codegen/compression_types.h>
-#include <grpc/impl/codegen/time.h>
struct gpr_timespec;
struct grpc_metadata;
diff --git a/include/grpc++/impl/codegen/server_interface.h b/include/grpc++/impl/codegen/server_interface.h
index 20e418d76e..4a00d7a3a1 100644
--- a/include/grpc++/impl/codegen/server_interface.h
+++ b/include/grpc++/impl/codegen/server_interface.h
@@ -52,6 +52,8 @@ class ServerCredentials;
class Service;
class ThreadPoolInterface;
+extern CoreCodegenInterface* g_core_codegen_interface;
+
/// Models a gRPC server.
///
/// Servers are configured and started via \a grpc::ServerBuilder.
@@ -78,7 +80,10 @@ class ServerInterface : public CallHook {
/// All completion queue associated with the server (for example, for async
/// serving) must be shutdown *after* this method has returned:
/// See \a ServerBuilder::AddCompletionQueue for details.
- void Shutdown() { ShutdownInternal(gpr_inf_future(GPR_CLOCK_MONOTONIC)); }
+ void Shutdown() {
+ ShutdownInternal(
+ g_core_codegen_interface->gpr_inf_future(GPR_CLOCK_MONOTONIC));
+ }
/// Block waiting for all work to complete.
///
diff --git a/include/grpc++/impl/codegen/status_helper.h b/include/grpc++/impl/codegen/status_helper.h
new file mode 100644
index 0000000000..bfe45d9e5b
--- /dev/null
+++ b/include/grpc++/impl/codegen/status_helper.h
@@ -0,0 +1,47 @@
+/*
+ *
+ * Copyright 2016, Google Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
+
+#ifndef GRPCXX_IMPL_CODEGEN_STATUS_HELPER_H
+#define GRPCXX_IMPL_CODEGEN_STATUS_HELPER_H
+
+#include <grpc++/impl/codegen/status.h>
+
+namespace grpc {
+
+inline StatusCode GetCanonicalCode(const Status& status) {
+ return status.error_code();
+}
+
+} // namespace grpc
+
+#endif // GRPCXX_IMPL_CODEGEN_STATUS_HELPER_H
diff --git a/include/grpc++/impl/codegen/sync_no_cxx11.h b/include/grpc++/impl/codegen/sync_no_cxx11.h
index 55c059ede7..87a6594f7d 100644
--- a/include/grpc++/impl/codegen/sync_no_cxx11.h
+++ b/include/grpc++/impl/codegen/sync_no_cxx11.h
@@ -34,18 +34,20 @@
#ifndef GRPCXX_IMPL_CODEGEN_SYNC_NO_CXX11_H
#define GRPCXX_IMPL_CODEGEN_SYNC_NO_CXX11_H
-#include <grpc/impl/codegen/sync.h>
+#include <grpc++/impl/codegen/core_codegen_interface.h>
namespace grpc {
+extern CoreCodegenInterface *g_core_codegen_interface;
+
template <class mutex>
class lock_guard;
class condition_variable;
class mutex {
public:
- mutex() { gpr_mu_init(&mu_); }
- ~mutex() { gpr_mu_destroy(&mu_); }
+ mutex() { g_core_codegen_interface->gpr_mu_init(&mu_); }
+ ~mutex() { g_core_codegen_interface->gpr_mu_destroy(&mu_); }
private:
::gpr_mu mu_;
@@ -57,16 +59,18 @@ class mutex {
template <class mutex>
class lock_guard {
public:
- lock_guard(mutex &mu) : mu_(mu), locked(true) { gpr_mu_lock(&mu.mu_); }
+ lock_guard(mutex &mu) : mu_(mu), locked(true) {
+ g_core_codegen_interface->gpr_mu_lock(&mu.mu_);
+ }
~lock_guard() { unlock_internal(); }
protected:
void lock_internal() {
- if (!locked) gpr_mu_lock(&mu_.mu_);
+ if (!locked) g_core_codegen_interface->gpr_mu_lock(&mu_.mu_);
locked = true;
}
void unlock_internal() {
- if (locked) gpr_mu_unlock(&mu_.mu_);
+ if (locked) g_core_codegen_interface->gpr_mu_unlock(&mu_.mu_);
locked = false;
}
@@ -86,15 +90,17 @@ class unique_lock : public lock_guard<mutex> {
class condition_variable {
public:
- condition_variable() { gpr_cv_init(&cv_); }
- ~condition_variable() { gpr_cv_destroy(&cv_); }
+ condition_variable() { g_core_codegen_interface->gpr_cv_init(&cv_); }
+ ~condition_variable() { g_core_codegen_interface->gpr_cv_destroy(&cv_); }
void wait(lock_guard<mutex> &mu) {
mu.locked = false;
- gpr_cv_wait(&cv_, &mu.mu_.mu_, gpr_inf_future(GPR_CLOCK_REALTIME));
+ g_core_codegen_interface->gpr_cv_wait(
+ &cv_, &mu.mu_.mu_,
+ g_core_codegen_interface->gpr_inf_future(GPR_CLOCK_REALTIME));
mu.locked = true;
}
- void notify_one() { gpr_cv_signal(&cv_); }
- void notify_all() { gpr_cv_broadcast(&cv_); }
+ void notify_one() { g_core_codegen_interface->gpr_cv_signal(&cv_); }
+ void notify_all() { g_core_codegen_interface->gpr_cv_broadcast(&cv_); }
private:
gpr_cv cv_;
diff --git a/include/grpc++/impl/codegen/sync_stream.h b/include/grpc++/impl/codegen/sync_stream.h
index 8249717d6c..e3c5a919b1 100644
--- a/include/grpc++/impl/codegen/sync_stream.h
+++ b/include/grpc++/impl/codegen/sync_stream.h
@@ -42,7 +42,6 @@
#include <grpc++/impl/codegen/server_context.h>
#include <grpc++/impl/codegen/service_type.h>
#include <grpc++/impl/codegen/status.h>
-#include <grpc/impl/codegen/log.h>
namespace grpc {
diff --git a/include/grpc++/impl/codegen/thrift_serializer.h b/include/grpc++/impl/codegen/thrift_serializer.h
index 7308a1577c..fd324a994f 100644
--- a/include/grpc++/impl/codegen/thrift_serializer.h
+++ b/include/grpc++/impl/codegen/thrift_serializer.h
@@ -34,10 +34,8 @@
#ifndef GRPCXX_IMPL_CODEGEN_THRIFT_SERIALIZER_H
#define GRPCXX_IMPL_CODEGEN_THRIFT_SERIALIZER_H
-#include <grpc/impl/codegen/byte_buffer.h>
#include <grpc/impl/codegen/byte_buffer_reader.h>
#include <grpc/impl/codegen/slice.h>
-#include <grpc/impl/codegen/slice_buffer.h>
#include <thrift/protocol/TBinaryProtocol.h>
#include <thrift/protocol/TCompactProtocol.h>
#include <thrift/protocol/TProtocolException.h>
@@ -216,4 +214,4 @@ typedef ThriftSerializer<void, TCompactProtocolT<TBufferBase>>
} // namespace thrift
} // namespace apache
-#endif \ No newline at end of file
+#endif
diff --git a/include/grpc++/impl/codegen/thrift_utils.h b/include/grpc++/impl/codegen/thrift_utils.h
index 3615e27474..742d739703 100644
--- a/include/grpc++/impl/codegen/thrift_utils.h
+++ b/include/grpc++/impl/codegen/thrift_utils.h
@@ -40,10 +40,8 @@
#include <grpc++/impl/codegen/status.h>
#include <grpc++/impl/codegen/status_code_enum.h>
#include <grpc++/impl/codegen/thrift_serializer.h>
-#include <grpc/impl/codegen/byte_buffer.h>
#include <grpc/impl/codegen/byte_buffer_reader.h>
#include <grpc/impl/codegen/slice.h>
-#include <grpc/impl/codegen/slice_buffer.h>
#include <cstdint>
#include <cstdlib>
diff --git a/include/grpc++/impl/codegen/time.h b/include/grpc++/impl/codegen/time.h
index d9b19bce64..87c5112d0d 100644
--- a/include/grpc++/impl/codegen/time.h
+++ b/include/grpc++/impl/codegen/time.h
@@ -35,7 +35,7 @@
#define GRPCXX_IMPL_CODEGEN_TIME_H
#include <grpc++/impl/codegen/config.h>
-#include <grpc/impl/codegen/time.h>
+#include <grpc/impl/codegen/grpc_types.h>
namespace grpc {
@@ -79,7 +79,7 @@ class TimePoint<gpr_timespec> {
#include <chrono>
-#include <grpc/impl/codegen/time.h>
+#include <grpc/impl/codegen/grpc_types.h>
namespace grpc {