Skip to content
Snippets Groups Projects
Commit 5c6e6276 authored by Craig Tiller's avatar Craig Tiller
Browse files

Merge github.com:grpc/grpc into shutdown-c++

parents e50e5cbd 4f21d354
No related branches found
No related tags found
No related merge requests found
Showing
with 63 additions and 70 deletions
...@@ -121,8 +121,8 @@ class ServerAsyncResponseWriter GRPC_FINAL ...@@ -121,8 +121,8 @@ class ServerAsyncResponseWriter GRPC_FINAL
} }
// The response is dropped if the status is not OK. // The response is dropped if the status is not OK.
if (status.ok()) { if (status.ok()) {
finish_buf_.ServerSendStatus( finish_buf_.ServerSendStatus(ctx_->trailing_metadata_,
ctx_->trailing_metadata_, finish_buf_.SendMessage(msg)); finish_buf_.SendMessage(msg));
} else { } else {
finish_buf_.ServerSendStatus(ctx_->trailing_metadata_, status); finish_buf_.ServerSendStatus(ctx_->trailing_metadata_, status);
} }
......
...@@ -62,6 +62,7 @@ class AuthPropertyIterator ...@@ -62,6 +62,7 @@ class AuthPropertyIterator
AuthPropertyIterator(); AuthPropertyIterator();
AuthPropertyIterator(const grpc_auth_property* property, AuthPropertyIterator(const grpc_auth_property* property,
const grpc_auth_property_iterator* iter); const grpc_auth_property_iterator* iter);
private: private:
friend class SecureAuthContext; friend class SecureAuthContext;
const grpc_auth_property* property_; const grpc_auth_property* property_;
...@@ -92,4 +93,3 @@ class AuthContext { ...@@ -92,4 +93,3 @@ class AuthContext {
} // namespace grpc } // namespace grpc
#endif // GRPCXX_AUTH_CONTEXT_H #endif // GRPCXX_AUTH_CONTEXT_H
...@@ -185,7 +185,9 @@ class ClientContext { ...@@ -185,7 +185,9 @@ class ClientContext {
// Get and set census context // Get and set census context
void set_census_context(struct census_context* ccp) { census_context_ = ccp; } void set_census_context(struct census_context* ccp) { census_context_ = ccp; }
struct census_context* census_context() const { return census_context_; } struct census_context* census_context() const {
return census_context_;
}
void TryCancel(); void TryCancel();
......
...@@ -58,6 +58,7 @@ class DynamicThreadPool GRPC_FINAL : public ThreadPoolInterface { ...@@ -58,6 +58,7 @@ class DynamicThreadPool GRPC_FINAL : public ThreadPoolInterface {
public: public:
DynamicThread(DynamicThreadPool* pool); DynamicThread(DynamicThreadPool* pool);
~DynamicThread(); ~DynamicThread();
private: private:
DynamicThreadPool* pool_; DynamicThreadPool* pool_;
std::unique_ptr<grpc::thread> thd_; std::unique_ptr<grpc::thread> thd_;
......
...@@ -52,8 +52,8 @@ class GenericStub GRPC_FINAL { ...@@ -52,8 +52,8 @@ class GenericStub GRPC_FINAL {
// begin a call to a named method // begin a call to a named method
std::unique_ptr<GenericClientAsyncReaderWriter> Call( std::unique_ptr<GenericClientAsyncReaderWriter> Call(
ClientContext* context, const grpc::string& method, ClientContext* context, const grpc::string& method, CompletionQueue* cq,
CompletionQueue* cq, void* tag); void* tag);
private: private:
std::shared_ptr<ChannelInterface> channel_; std::shared_ptr<ChannelInterface> channel_;
......
...@@ -67,14 +67,10 @@ class WriteOptions { ...@@ -67,14 +67,10 @@ class WriteOptions {
WriteOptions(const WriteOptions& other) : flags_(other.flags_) {} WriteOptions(const WriteOptions& other) : flags_(other.flags_) {}
/// Clear all flags. /// Clear all flags.
inline void Clear() { inline void Clear() { flags_ = 0; }
flags_ = 0;
}
/// Returns raw flags bitset. /// Returns raw flags bitset.
inline gpr_uint32 flags() const { inline gpr_uint32 flags() const { return flags_; }
return flags_;
}
/// Sets flag for the disabling of compression for the next message write. /// Sets flag for the disabling of compression for the next message write.
/// ///
...@@ -122,9 +118,7 @@ class WriteOptions { ...@@ -122,9 +118,7 @@ class WriteOptions {
/// not go out on the wire immediately. /// not go out on the wire immediately.
/// ///
/// \sa GRPC_WRITE_BUFFER_HINT /// \sa GRPC_WRITE_BUFFER_HINT
inline bool get_buffer_hint() const { inline bool get_buffer_hint() const { return GetBit(GRPC_WRITE_BUFFER_HINT); }
return GetBit(GRPC_WRITE_BUFFER_HINT);
}
WriteOptions& operator=(const WriteOptions& rhs) { WriteOptions& operator=(const WriteOptions& rhs) {
flags_ = rhs.flags_; flags_ = rhs.flags_;
...@@ -132,17 +126,11 @@ class WriteOptions { ...@@ -132,17 +126,11 @@ class WriteOptions {
} }
private: private:
void SetBit(const gpr_int32 mask) { void SetBit(const gpr_int32 mask) { flags_ |= mask; }
flags_ |= mask;
}
void ClearBit(const gpr_int32 mask) { void ClearBit(const gpr_int32 mask) { flags_ &= ~mask; }
flags_ &= ~mask;
}
bool GetBit(const gpr_int32 mask) const { bool GetBit(const gpr_int32 mask) const { return flags_ & mask; }
return flags_ & mask;
}
gpr_uint32 flags_; gpr_uint32 flags_;
}; };
......
...@@ -46,5 +46,4 @@ class GrpcLibrary { ...@@ -46,5 +46,4 @@ class GrpcLibrary {
} // namespace grpc } // namespace grpc
#endif // GRPCXX_IMPL_GRPC_LIBRARY_H #endif // GRPCXX_IMPL_GRPC_LIBRARY_H
...@@ -46,6 +46,7 @@ class mutex { ...@@ -46,6 +46,7 @@ class mutex {
public: public:
mutex() { gpr_mu_init(&mu_); } mutex() { gpr_mu_init(&mu_); }
~mutex() { gpr_mu_destroy(&mu_); } ~mutex() { gpr_mu_destroy(&mu_); }
private: private:
::gpr_mu mu_; ::gpr_mu mu_;
template <class mutex> template <class mutex>
...@@ -58,6 +59,7 @@ class lock_guard { ...@@ -58,6 +59,7 @@ class lock_guard {
public: public:
lock_guard(mutex &mu) : mu_(mu), locked(true) { gpr_mu_lock(&mu.mu_); } lock_guard(mutex &mu) : mu_(mu), locked(true) { gpr_mu_lock(&mu.mu_); }
~lock_guard() { unlock_internal(); } ~lock_guard() { unlock_internal(); }
protected: protected:
void lock_internal() { void lock_internal() {
if (!locked) gpr_mu_lock(&mu_.mu_); if (!locked) gpr_mu_lock(&mu_.mu_);
...@@ -67,6 +69,7 @@ class lock_guard { ...@@ -67,6 +69,7 @@ class lock_guard {
if (locked) gpr_mu_unlock(&mu_.mu_); if (locked) gpr_mu_unlock(&mu_.mu_);
locked = false; locked = false;
} }
private: private:
mutex &mu_; mutex &mu_;
bool locked; bool locked;
...@@ -92,6 +95,7 @@ class condition_variable { ...@@ -92,6 +95,7 @@ class condition_variable {
} }
void notify_one() { gpr_cv_signal(&cv_); } void notify_one() { gpr_cv_signal(&cv_); }
void notify_all() { gpr_cv_broadcast(&cv_); } void notify_all() { gpr_cv_broadcast(&cv_); }
private: private:
gpr_cv cv_; gpr_cv cv_;
}; };
......
...@@ -40,7 +40,8 @@ namespace grpc { ...@@ -40,7 +40,8 @@ namespace grpc {
class thread { class thread {
public: public:
template<class T> thread(void (T::*fptr)(), T *obj) { template <class T>
thread(void (T::*fptr)(), T *obj) {
func_ = new thread_function<T>(fptr, obj); func_ = new thread_function<T>(fptr, obj);
joined_ = false; joined_ = false;
start(); start();
...@@ -53,6 +54,7 @@ class thread { ...@@ -53,6 +54,7 @@ class thread {
gpr_thd_join(thd_); gpr_thd_join(thd_);
joined_ = true; joined_ = true;
} }
private: private:
void start() { void start() {
gpr_thd_options options = gpr_thd_options_default(); gpr_thd_options options = gpr_thd_options_default();
...@@ -71,10 +73,9 @@ class thread { ...@@ -71,10 +73,9 @@ class thread {
template <class T> template <class T>
class thread_function : public thread_function_base { class thread_function : public thread_function_base {
public: public:
thread_function(void (T::*fptr)(), T *obj) thread_function(void (T::*fptr)(), T *obj) : fptr_(fptr), obj_(obj) {}
: fptr_(fptr)
, obj_(obj) { }
virtual void call() { (obj_->*fptr_)(); } virtual void call() { (obj_->*fptr_)(); }
private: private:
void (T::*fptr_)(); void (T::*fptr_)();
T *obj_; T *obj_;
......
...@@ -91,7 +91,8 @@ class Server GRPC_FINAL : public GrpcLibrary, private CallHook { ...@@ -91,7 +91,8 @@ class Server GRPC_FINAL : public GrpcLibrary, private CallHook {
// Register a service. This call does not take ownership of the service. // Register a service. This call does not take ownership of the service.
// The service must exist for the lifetime of the Server instance. // The service must exist for the lifetime of the Server instance.
bool RegisterService(const grpc::string* host, RpcService* service); bool RegisterService(const grpc::string* host, RpcService* service);
bool RegisterAsyncService(const grpc::string *host, AsynchronousService* service); bool RegisterAsyncService(const grpc::string* host,
AsynchronousService* service);
void RegisterAsyncGenericService(AsyncGenericService* service); void RegisterAsyncGenericService(AsyncGenericService* service);
// Add a listening port. Can be called multiple times. // Add a listening port. Can be called multiple times.
int AddListeningPort(const grpc::string& addr, ServerCredentials* creds); int AddListeningPort(const grpc::string& addr, ServerCredentials* creds);
......
...@@ -76,8 +76,7 @@ class ServerBuilder { ...@@ -76,8 +76,7 @@ class ServerBuilder {
// The service must exist for the lifetime of the Server instance returned by // The service must exist for the lifetime of the Server instance returned by
// BuildAndStart(). // BuildAndStart().
// Only matches requests with :authority \a host // Only matches requests with :authority \a host
void RegisterService(const grpc::string& host, void RegisterService(const grpc::string& host, SynchronousService* service);
SynchronousService* service);
// Register an asynchronous service. // Register an asynchronous service.
// This call does not take ownership of the service or completion queue. // This call does not take ownership of the service or completion queue.
...@@ -117,7 +116,8 @@ class ServerBuilder { ...@@ -117,7 +116,8 @@ class ServerBuilder {
}; };
typedef std::unique_ptr<grpc::string> HostString; typedef std::unique_ptr<grpc::string> HostString;
template <class T> struct NamedService { template <class T>
struct NamedService {
explicit NamedService(T* s) : service(s) {} explicit NamedService(T* s) : service(s) {}
NamedService(const grpc::string& h, T* s) NamedService(const grpc::string& h, T* s)
: host(new grpc::string(h)), service(s) {} : host(new grpc::string(h)), service(s) {}
...@@ -127,7 +127,8 @@ class ServerBuilder { ...@@ -127,7 +127,8 @@ class ServerBuilder {
int max_message_size_; int max_message_size_;
std::vector<std::unique_ptr<NamedService<RpcService>>> services_; std::vector<std::unique_ptr<NamedService<RpcService>>> services_;
std::vector<std::unique_ptr<NamedService<AsynchronousService>>> async_services_; std::vector<std::unique_ptr<NamedService<AsynchronousService>>>
async_services_;
std::vector<Port> ports_; std::vector<Port> ports_;
std::vector<ServerCompletionQueue*> cqs_; std::vector<ServerCompletionQueue*> cqs_;
std::shared_ptr<ServerCredentials> creds_; std::shared_ptr<ServerCredentials> creds_;
......
...@@ -85,9 +85,7 @@ class WriterInterface { ...@@ -85,9 +85,7 @@ class WriterInterface {
// Returns false when the stream has been closed. // Returns false when the stream has been closed.
virtual bool Write(const W& msg, const WriteOptions& options) = 0; virtual bool Write(const W& msg, const WriteOptions& options) = 0;
inline bool Write(const W& msg) { inline bool Write(const W& msg) { return Write(msg, WriteOptions()); }
return Write(msg, WriteOptions());
}
}; };
template <class R> template <class R>
...@@ -640,8 +638,7 @@ class ServerAsyncReader GRPC_FINAL : public ServerAsyncStreamingInterface, ...@@ -640,8 +638,7 @@ class ServerAsyncReader GRPC_FINAL : public ServerAsyncStreamingInterface,
} }
// The response is dropped if the status is not OK. // The response is dropped if the status is not OK.
if (status.ok()) { if (status.ok()) {
finish_ops_.ServerSendStatus( finish_ops_.ServerSendStatus(ctx_->trailing_metadata_,
ctx_->trailing_metadata_,
finish_ops_.SendMessage(msg)); finish_ops_.SendMessage(msg));
} else { } else {
finish_ops_.ServerSendStatus(ctx_->trailing_metadata_, status); finish_ops_.ServerSendStatus(ctx_->trailing_metadata_, status);
......
...@@ -629,8 +629,7 @@ grpc_call_error grpc_server_request_registered_call( ...@@ -629,8 +629,7 @@ grpc_call_error grpc_server_request_registered_call(
be specified with args. If no additional configuration is needed, args can be specified with args. If no additional configuration is needed, args can
be NULL. See grpc_channel_args for more. The data in 'args' need only live be NULL. See grpc_channel_args for more. The data in 'args' need only live
through the invocation of this function. */ through the invocation of this function. */
grpc_server *grpc_server_create(const grpc_channel_args *args, grpc_server *grpc_server_create(const grpc_channel_args *args, void *reserved);
void *reserved);
/** Register a completion queue with the server. Must be done for any /** Register a completion queue with the server. Must be done for any
notification completion queue that is passed to grpc_server_request_*_call notification completion queue that is passed to grpc_server_request_*_call
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment