34 #ifndef GRPCXX_SERVER_H 
   35 #define GRPCXX_SERVER_H 
   52 class AsynchronousService;
 
   53 class GenericServerContext;
 
   54 class AsyncGenericService;
 
   56 class RpcServiceMethod;
 
   57 class ServerAsyncStreamingInterface;
 
   58 class ThreadPoolInterface;
 
   78   void Shutdown() { ShutdownInternal(gpr_inf_future(GPR_CLOCK_MONOTONIC)); }
 
   93   class ShutdownRequest;
 
  101   Server(ThreadPoolInterface* thread_pool, 
bool thread_pool_owned,
 
  102          int max_message_size);
 
  140   void HandleQueueClosed();
 
  146   void ScheduleCallback();
 
  150   void ShutdownInternal(gpr_timespec deadline);
 
  157                      bool delete_on_finalize);
 
  158     virtual ~BaseAsyncRequest();
 
  168     const bool delete_on_finalize_;
 
  170     grpc_metadata_array initial_metadata_array_;
 
  173   class RegisteredAsyncRequest : 
public BaseAsyncRequest {
 
  182     void IssueRequest(
void* registered_method, grpc_byte_buffer** payload,
 
  186   class NoPayloadAsyncRequest 
GRPC_FINAL : 
public RegisteredAsyncRequest {
 
  188     NoPayloadAsyncRequest(
void* registered_method, Server* server,
 
  189                           ServerContext* context,
 
  190                           ServerAsyncStreamingInterface* stream,
 
  191                           CompletionQueue* call_cq,
 
  192                           ServerCompletionQueue* notification_cq, 
void* tag)
 
  193         : RegisteredAsyncRequest(server, context, stream, call_cq, tag) {
 
  194       IssueRequest(registered_method, 
nullptr, notification_cq);
 
  200   template <
class Message>
 
  201   class PayloadAsyncRequest 
GRPC_FINAL : 
public RegisteredAsyncRequest {
 
  203     PayloadAsyncRequest(
void* registered_method, Server* server,
 
  204                         ServerContext* context,
 
  205                         ServerAsyncStreamingInterface* stream,
 
  206                         CompletionQueue* call_cq,
 
  207                         ServerCompletionQueue* notification_cq, 
void* tag,
 
  209         : RegisteredAsyncRequest(server, context, stream, call_cq, tag),
 
  211       IssueRequest(registered_method, &payload_, notification_cq);
 
  214     bool FinalizeResult(
void** tag, 
bool* status) 
GRPC_OVERRIDE {
 
  215       bool serialization_status =
 
  216           *status && payload_ &&
 
  217           SerializationTraits<Message>::Deserialize(payload_, request_,
 
  218                                                     server_->max_message_size_)
 
  220       bool ret = RegisteredAsyncRequest::FinalizeResult(tag, status);
 
  221       *status = serialization_status && *status;
 
  226     grpc_byte_buffer* payload_;
 
  230   class GenericAsyncRequest : 
public BaseAsyncRequest {
 
  232     GenericAsyncRequest(Server* server, GenericServerContext* context,
 
  233                         ServerAsyncStreamingInterface* stream,
 
  234                         CompletionQueue* call_cq,
 
  235                         ServerCompletionQueue* notification_cq, 
void* tag,
 
  236                         bool delete_on_finalize);
 
  241     grpc_call_details call_details_;
 
  244   class UnimplementedAsyncRequestContext;
 
  245   class UnimplementedAsyncRequest;
 
  246   class UnimplementedAsyncResponse;
 
  248   template <
class Message>
 
  249   void RequestAsyncCall(
void* registered_method, ServerContext* context,
 
  250                         ServerAsyncStreamingInterface* stream,
 
  251                         CompletionQueue* call_cq,
 
  252                         ServerCompletionQueue* notification_cq, 
void* tag,
 
  254     new PayloadAsyncRequest<Message>(registered_method, 
this, context, stream,
 
  255                                      call_cq, notification_cq, tag, message);
 
  258   void RequestAsyncCall(
void* registered_method, ServerContext* context,
 
  259                         ServerAsyncStreamingInterface* stream,
 
  260                         CompletionQueue* call_cq,
 
  261                         ServerCompletionQueue* notification_cq, 
void* tag) {
 
  262     new NoPayloadAsyncRequest(registered_method, 
this, context, stream, call_cq,
 
  263                               notification_cq, tag);
 
  266   void RequestAsyncGenericCall(GenericServerContext* context,
 
  267                                ServerAsyncStreamingInterface* stream,
 
  268                                CompletionQueue* call_cq,
 
  269                                ServerCompletionQueue* notification_cq,
 
  271     new GenericAsyncRequest(
this, context, stream, call_cq, notification_cq,
 
  275   const int max_message_size_;
 
  288   std::list<SyncRequest>* sync_methods_;
 
  289   std::unique_ptr<RpcServiceMethod> unknown_method_;
 
  290   bool has_generic_service_;
 
  293   grpc_server* 
const server_;
 
  295   ThreadPoolInterface* thread_pool_;
 
  297   bool thread_pool_owned_;
 
  302 #endif  // GRPCXX_SERVER_H 
An interface allowing implementors to process and filter event tags. 
Definition: completion_queue.h:192
 
void Shutdown()
Shutdown the server, waiting for all rpc processing to finish. 
Definition: server.h:78
 
std::string string
Definition: config.h:112
 
An abstract collection of call ops, used to generate the grpc_call_op structure to pass down to the l...
Definition: call.h:478
 
Definition: service_type.h:68
 
void Shutdown(const T &deadline)
Shutdown the server, blocking until all rpc processing finishes. 
Definition: server.h:73
 
Definition: sync_no_cxx11.h:45
 
Definition: service_type.h:57
 
#define GRPC_FINAL
Definition: config.h:71
 
Definition: async_generic_service.h:59
 
Definition: sync_no_cxx11.h:87
 
Definition: grpc_library.h:41
 
Definition: rpc_service_method.h:248
 
Definition: server_credentials.h:49
 
Models a gRPC server. 
Definition: server.h:63
 
void Wait()
Block waiting for all work to complete. 
 
Definition: server_context.h:89
 
A thin wrapper around grpc_completion_queue (see / src/core/surface/completion_queue.h). 
Definition: completion_queue.h:81
 
A specific type of completion queue used by the processing of notifications by servers. 
Definition: completion_queue.h:204
 
#define GRPC_OVERRIDE
Definition: config.h:77
 
A builder class for the creation and startup of grpc::Server instances. 
Definition: server_builder.h:55
 
::google::protobuf::Message Message
Definition: config_protobuf.h:60