aboutsummaryrefslogtreecommitdiffhomepage
path: root/include
diff options
context:
space:
mode:
authorGravatar Hongwei Wang <hongweiw@google.com>2015-07-31 15:22:13 -0700
committerGravatar Hongwei Wang <hongweiw@google.com>2015-07-31 15:22:13 -0700
commit12845527139b5ce7b850e1bbb132fdb9de45bc88 (patch)
treecb364c4c982f8956225d266b9997e2e4479f13ca /include
parent8e04d4107ef07c5914b84f14d4f1b0771090c1b0 (diff)
parent11af9747152565c4f5bfe0acb453715521e8af7f (diff)
Merge branch 'master' of https://github.com/grpc/grpc into zookeeper
Diffstat (limited to 'include')
-rw-r--r--include/grpc++/client_context.h8
-rw-r--r--include/grpc++/dynamic_thread_pool.h1
-rw-r--r--include/grpc++/impl/sync_no_cxx11.h2
-rw-r--r--include/grpc++/server_context.h7
-rw-r--r--include/grpc/census.h32
-rw-r--r--include/grpc/grpc.h48
-rw-r--r--include/grpc/support/atm_gcc_atomic.h2
-rw-r--r--include/grpc/support/atm_gcc_sync.h5
-rw-r--r--include/grpc/support/atm_win32.h5
9 files changed, 72 insertions, 38 deletions
diff --git a/include/grpc++/client_context.h b/include/grpc++/client_context.h
index 9df76699d2..5cf4d3328a 100644
--- a/include/grpc++/client_context.h
+++ b/include/grpc++/client_context.h
@@ -110,7 +110,7 @@ class ClientContext {
creds_ = creds;
}
- grpc_compression_algorithm get_compression_algorithm() const {
+ grpc_compression_algorithm compression_algorithm() const {
return compression_algorithm_;
}
@@ -119,8 +119,8 @@ class ClientContext {
std::shared_ptr<const AuthContext> auth_context() const;
// Get and set census context
- void set_census_context(census_context* ccp) { census_context_ = ccp; }
- census_context* get_census_context() const { return census_context_; }
+ void set_census_context(struct census_context* ccp) { census_context_ = ccp; }
+ struct census_context* census_context() const { return census_context_; }
void TryCancel();
@@ -170,7 +170,7 @@ class ClientContext {
grpc::string authority_;
std::shared_ptr<Credentials> creds_;
mutable std::shared_ptr<const AuthContext> auth_context_;
- census_context* census_context_;
+ struct census_context* census_context_;
std::multimap<grpc::string, grpc::string> send_initial_metadata_;
std::multimap<grpc::string, grpc::string> recv_initial_metadata_;
std::multimap<grpc::string, grpc::string> trailing_metadata_;
diff --git a/include/grpc++/dynamic_thread_pool.h b/include/grpc++/dynamic_thread_pool.h
index bc4e2d4d74..f0cd35940f 100644
--- a/include/grpc++/dynamic_thread_pool.h
+++ b/include/grpc++/dynamic_thread_pool.h
@@ -41,6 +41,7 @@
#include <grpc++/thread_pool_interface.h>
#include <list>
+#include <memory>
#include <queue>
namespace grpc {
diff --git a/include/grpc++/impl/sync_no_cxx11.h b/include/grpc++/impl/sync_no_cxx11.h
index fda668957e..5869b04c76 100644
--- a/include/grpc++/impl/sync_no_cxx11.h
+++ b/include/grpc++/impl/sync_no_cxx11.h
@@ -87,7 +87,7 @@ class condition_variable {
~condition_variable() { 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);
+ gpr_cv_wait(&cv_, &mu.mu_.mu_, gpr_inf_future(GPR_CLOCK_REALTIME));
mu.locked = true;
}
void notify_one() { gpr_cv_signal(&cv_); }
diff --git a/include/grpc++/server_context.h b/include/grpc++/server_context.h
index 3bfa48fbb6..e204d66456 100644
--- a/include/grpc++/server_context.h
+++ b/include/grpc++/server_context.h
@@ -46,6 +46,7 @@
struct gpr_timespec;
struct grpc_metadata;
struct grpc_call;
+struct census_context;
namespace grpc {
@@ -104,18 +105,20 @@ class ServerContext {
return client_metadata_;
}
- grpc_compression_level get_compression_level() const {
+ grpc_compression_level compression_level() const {
return compression_level_;
}
void set_compression_level(grpc_compression_level level);
- grpc_compression_algorithm get_compression_algorithm() const {
+ grpc_compression_algorithm compression_algorithm() const {
return compression_algorithm_;
}
void set_compression_algorithm(grpc_compression_algorithm algorithm);
std::shared_ptr<const AuthContext> auth_context() const;
+ const struct census_context* census_context() const;
+
private:
friend class ::grpc::testing::InteropContextInspector;
friend class ::grpc::Server;
diff --git a/include/grpc/census.h b/include/grpc/census.h
index 379783905a..7603dfdce1 100644
--- a/include/grpc/census.h
+++ b/include/grpc/census.h
@@ -44,26 +44,30 @@
extern "C" {
#endif
-/* Identify census functionality that can be enabled via census_initialize(). */
-enum census_functions {
- CENSUS_NONE = 0, /* Do not enable census. */
- CENSUS_TRACING = 1, /* Enable census tracing. */
- CENSUS_STATS = 2, /* Enable Census stats collection. */
- CENSUS_CPU = 4, /* Enable Census CPU usage collection. */
- CENSUS_ALL = CENSUS_TRACING | CENSUS_STATS | CENSUS_CPU
+/* Identify census features that can be enabled via census_initialize(). */
+enum census_features {
+ CENSUS_FEATURE_NONE = 0, /* Do not enable census. */
+ CENSUS_FEATURE_TRACING = 1, /* Enable census tracing. */
+ CENSUS_FEATURE_STATS = 2, /* Enable Census stats collection. */
+ CENSUS_FEATURE_CPU = 4, /* Enable Census CPU usage collection. */
+ CENSUS_FEATURE_ALL =
+ CENSUS_FEATURE_TRACING | CENSUS_FEATURE_STATS | CENSUS_FEATURE_CPU
};
-/* Shutdown and startup census subsystem. The 'functions' argument should be
- * the OR (|) of census_functions values. If census fails to initialize, then
+/** Shutdown and startup census subsystem. The 'features' argument should be
+ * the OR (|) of census_features values. If census fails to initialize, then
* census_initialize() will return a non-zero value. It is an error to call
* census_initialize() more than once (without an intervening
* census_shutdown()). */
-int census_initialize(int functions);
-void census_shutdown();
+int census_initialize(int features);
+void census_shutdown(void);
-/* If any census feature has been initialized, this funtion will return a
- * non-zero value. */
-int census_available();
+/** Return the features supported by the current census implementation (not all
+ * features will be available on all platforms). */
+int census_supported(void);
+
+/** Return the census features currently enabled. */
+int census_enabled(void);
/* Internally, Census relies on a context, which should be propagated across
* RPC's. From the RPC subsystems viewpoint, this is an opaque data structure.
diff --git a/include/grpc/grpc.h b/include/grpc/grpc.h
index 901ec8f5b7..69cef9d77b 100644
--- a/include/grpc/grpc.h
+++ b/include/grpc/grpc.h
@@ -50,7 +50,7 @@ extern "C" {
* \section intro_sec The GRPC Core library is a low-level library designed
* to be wrapped by higher level libraries.
*
- * The top-level API is provided in grpc.h.
+ * The top-level API is provided in grpc.h.
* Security related functionality lives in grpc_security.h.
*/
@@ -175,7 +175,7 @@ typedef enum grpc_call_error {
GRPC_CALL_ERROR_INVALID_FLAGS,
/** invalid metadata was passed to this call */
GRPC_CALL_ERROR_INVALID_METADATA,
- /** completion queue for notification has not been registered with the
+ /** completion queue for notification has not been registered with the
server */
GRPC_CALL_ERROR_NOT_SERVER_COMPLETION_QUEUE
} grpc_call_error;
@@ -198,7 +198,8 @@ typedef struct grpc_metadata {
size_t value_length;
/** The following fields are reserved for grpc internal use.
- There is no need to initialize them, and they will be set to garbage during
+ There is no need to initialize them, and they will be set to garbage
+ during
calls to grpc. */
struct {
void *obfuscated[3];
@@ -256,24 +257,25 @@ typedef enum {
/** Send a message: 0 or more of these operations can occur for each call */
GRPC_OP_SEND_MESSAGE,
/** Send a close from the client: one and only one instance MUST be sent from
- the client, unless the call was cancelled - in which case this can be
+ the client, unless the call was cancelled - in which case this can be
skipped */
GRPC_OP_SEND_CLOSE_FROM_CLIENT,
/** Send status from the server: one and only one instance MUST be sent from
- the server unless the call was cancelled - in which case this can be
+ the server unless the call was cancelled - in which case this can be
skipped */
GRPC_OP_SEND_STATUS_FROM_SERVER,
- /** Receive initial metadata: one and only one MUST be made on the client,
+ /** Receive initial metadata: one and only one MUST be made on the client,
must not be made on the server */
GRPC_OP_RECV_INITIAL_METADATA,
- /** Receive a message: 0 or more of these operations can occur for each call */
+ /** Receive a message: 0 or more of these operations can occur for each call
+ */
GRPC_OP_RECV_MESSAGE,
/** Receive status on the client: one and only one must be made on the client.
This operation always succeeds, meaning ops paired with this operation
will also appear to succeed, even though they may not have. In that case
the status will indicate some failure. */
GRPC_OP_RECV_STATUS_ON_CLIENT,
- /** Receive close on the server: one and only one must be made on the
+ /** Receive close on the server: one and only one must be made on the
server */
GRPC_OP_RECV_CLOSE_ON_SERVER
} grpc_op_type;
@@ -284,7 +286,7 @@ typedef struct grpc_op {
/** Operation type, as defined by grpc_op_type */
grpc_op_type op;
/** Write flags bitset for grpc_begin_messages */
- gpr_uint32 flags;
+ gpr_uint32 flags;
union {
struct {
size_t count;
@@ -303,21 +305,23 @@ typedef struct grpc_op {
After the operation completes, call grpc_metadata_array_destroy on this
value, or reuse it in a future op. */
grpc_metadata_array *recv_initial_metadata;
- /** ownership of the byte buffer is moved to the caller; the caller must call
+ /** ownership of the byte buffer is moved to the caller; the caller must
+ call
grpc_byte_buffer_destroy on this value, or reuse it in a future op. */
grpc_byte_buffer **recv_message;
struct {
/** ownership of the array is with the caller, but ownership of the
- elements stays with the call object (ie key, value members are owned
+ elements stays with the call object (ie key, value members are owned
by the call object, trailing_metadata->array is owned by the caller).
- After the operation completes, call grpc_metadata_array_destroy on this
+ After the operation completes, call grpc_metadata_array_destroy on
+ this
value, or reuse it in a future op. */
grpc_metadata_array *trailing_metadata;
grpc_status_code *status;
/** status_details is a buffer owned by the application before the op
completes and after the op has completed. During the operation
- status_details may be reallocated to a size larger than
- *status_details_capacity, in which case *status_details_capacity will
+ status_details may be reallocated to a size larger than
+ *status_details_capacity, in which case *status_details_capacity will
be updated with the new array capacity.
Pre-allocating space:
@@ -466,6 +470,16 @@ grpc_call_error grpc_call_start_batch(grpc_call *call, const grpc_op *ops,
functionality. Instead, use grpc_auth_context. */
char *grpc_call_get_peer(grpc_call *call);
+struct census_context;
+
+/* Set census context for a call; Must be called before first call to
+ grpc_call_start_batch(). */
+void grpc_census_call_set_context(grpc_call *call,
+ struct census_context *context);
+
+/* Retrieve the calls current census context. */
+struct census_context *grpc_census_call_get_context(grpc_call *call);
+
/** Return a newly allocated string representing the target a channel was
created for. */
char *grpc_channel_get_target(grpc_channel *channel);
@@ -512,7 +526,7 @@ grpc_call_error grpc_call_cancel_with_status(grpc_call *call,
void grpc_call_destroy(grpc_call *call);
/** Request notification of a new call. 'cq_for_notification' must
- have been registered to the server via
+ have been registered to the server via
grpc_server_register_completion_queue. */
grpc_call_error grpc_server_request_call(
grpc_server *server, grpc_call **call, grpc_call_details *details,
@@ -530,8 +544,8 @@ grpc_call_error grpc_server_request_call(
void *grpc_server_register_method(grpc_server *server, const char *method,
const char *host);
-/** Request notification of a new pre-registered call. 'cq_for_notification'
- must have been registered to the server via
+/** Request notification of a new pre-registered call. 'cq_for_notification'
+ must have been registered to the server via
grpc_server_register_completion_queue. */
grpc_call_error grpc_server_request_registered_call(
grpc_server *server, void *registered_method, grpc_call **call,
diff --git a/include/grpc/support/atm_gcc_atomic.h b/include/grpc/support/atm_gcc_atomic.h
index 65d3d0c60f..a2c8386028 100644
--- a/include/grpc/support/atm_gcc_atomic.h
+++ b/include/grpc/support/atm_gcc_atomic.h
@@ -46,6 +46,8 @@ typedef gpr_intptr gpr_atm;
#define gpr_atm_no_barrier_load(p) (__atomic_load_n((p), __ATOMIC_RELAXED))
#define gpr_atm_rel_store(p, value) \
(__atomic_store_n((p), (gpr_intptr)(value), __ATOMIC_RELEASE))
+#define gpr_atm_no_barrier_store(p, value) \
+ (__atomic_store_n((p), (gpr_intptr)(value), __ATOMIC_RELAXED))
#define gpr_atm_no_barrier_fetch_add(p, delta) \
(__atomic_fetch_add((p), (gpr_intptr)(delta), __ATOMIC_RELAXED))
diff --git a/include/grpc/support/atm_gcc_sync.h b/include/grpc/support/atm_gcc_sync.h
index 4955e4436f..38b5a9eec2 100644
--- a/include/grpc/support/atm_gcc_sync.h
+++ b/include/grpc/support/atm_gcc_sync.h
@@ -68,6 +68,11 @@ static __inline void gpr_atm_rel_store(gpr_atm *p, gpr_atm value) {
*p = value;
}
+static __inline void gpr_atm_no_barrier_store(gpr_atm *p, gpr_atm value) {
+ GPR_ATM_COMPILE_BARRIER_();
+ *p = value;
+}
+
#undef GPR_ATM_LS_BARRIER_
#undef GPR_ATM_COMPILE_BARRIER_
diff --git a/include/grpc/support/atm_win32.h b/include/grpc/support/atm_win32.h
index da99021c24..694528a9ba 100644
--- a/include/grpc/support/atm_win32.h
+++ b/include/grpc/support/atm_win32.h
@@ -57,6 +57,11 @@ static __inline void gpr_atm_rel_store(gpr_atm *p, gpr_atm value) {
*p = value;
}
+static __inline void gpr_atm_no_barrier_store(gpr_atm *p, gpr_atm value) {
+ /* TODO(ctiller): Can we implement something better here? */
+ gpr_atm_rel_store(p, value);
+}
+
static __inline int gpr_atm_no_barrier_cas(gpr_atm *p, gpr_atm o, gpr_atm n) {
/* InterlockedCompareExchangePointerNoFence() not available on vista or
windows7 */