34 #ifndef GRPCXX_SERVER_H
35 #define GRPCXX_SERVER_H
51 class AsynchronousService;
52 class GenericServerContext;
53 class AsyncGenericService;
55 class RpcServiceMethod;
56 class ServerAsyncStreamingInterface;
57 class ServerCredentials;
58 class ThreadPoolInterface;
80 class ShutdownRequest;
84 int max_message_size);
95 void HandleQueueClosed();
97 void ScheduleCallback();
106 virtual ~BaseAsyncRequest();
117 grpc_metadata_array initial_metadata_array_;
120 class RegisteredAsyncRequest :
public BaseAsyncRequest {
129 void IssueRequest(
void* registered_method, grpc_byte_buffer** payload,
133 class NoPayloadAsyncRequest
GRPC_FINAL :
public RegisteredAsyncRequest {
135 NoPayloadAsyncRequest(
void* registered_method, Server* server,
136 ServerContext* context,
137 ServerAsyncStreamingInterface* stream,
138 CompletionQueue* call_cq,
139 ServerCompletionQueue* notification_cq,
void* tag)
140 : RegisteredAsyncRequest(server, context, stream, call_cq, tag) {
141 IssueRequest(registered_method,
nullptr, notification_cq);
147 template <
class Message>
148 class PayloadAsyncRequest
GRPC_FINAL :
public RegisteredAsyncRequest {
150 PayloadAsyncRequest(
void* registered_method, Server* server,
151 ServerContext* context,
152 ServerAsyncStreamingInterface* stream,
153 CompletionQueue* call_cq,
154 ServerCompletionQueue* notification_cq,
void* tag,
156 : RegisteredAsyncRequest(server, context, stream, call_cq, tag),
158 IssueRequest(registered_method, &payload_, notification_cq);
161 bool FinalizeResult(
void** tag,
bool* status)
GRPC_OVERRIDE {
162 bool serialization_status =
163 *status && payload_ &&
164 SerializationTraits<Message>::Deserialize(payload_, request_,
165 server_->max_message_size_)
167 bool ret = RegisteredAsyncRequest::FinalizeResult(tag, status);
168 *status = serialization_status && *status;
173 grpc_byte_buffer* payload_;
177 class GenericAsyncRequest
GRPC_FINAL :
public BaseAsyncRequest {
179 GenericAsyncRequest(Server* server, GenericServerContext* context,
180 ServerAsyncStreamingInterface* stream,
181 CompletionQueue* call_cq,
182 ServerCompletionQueue* notification_cq,
void* tag);
187 grpc_call_details call_details_;
190 template <
class Message>
191 void RequestAsyncCall(
void* registered_method, ServerContext* context,
192 ServerAsyncStreamingInterface* stream,
193 CompletionQueue* call_cq,
194 ServerCompletionQueue* notification_cq,
void* tag,
196 new PayloadAsyncRequest<Message>(registered_method,
this, context, stream,
197 call_cq, notification_cq, tag, message);
200 void RequestAsyncCall(
void* registered_method, ServerContext* context,
201 ServerAsyncStreamingInterface* stream,
202 CompletionQueue* call_cq,
203 ServerCompletionQueue* notification_cq,
void* tag) {
204 new NoPayloadAsyncRequest(registered_method,
this, context, stream, call_cq,
205 notification_cq, tag);
208 void RequestAsyncGenericCall(GenericServerContext* context,
209 ServerAsyncStreamingInterface* stream,
210 CompletionQueue* call_cq,
211 ServerCompletionQueue* notification_cq,
213 new GenericAsyncRequest(
this, context, stream, call_cq, notification_cq,
217 const int max_message_size_;
230 std::list<SyncRequest>* sync_methods_;
233 grpc_server*
const server_;
235 ThreadPoolInterface* thread_pool_;
237 bool thread_pool_owned_;
242 #endif // GRPCXX_SERVER_H
Definition: completion_queue.h:75
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:482
Definition: service_type.h:68
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: thread_pool_interface.h:42
Definition: sync_no_cxx11.h:84
Definition: grpc_library.h:41
Definition: rpc_service_method.h:227
Definition: server_credentials.h:48
Definition: server_context.h:86
Definition: completion_queue.h:87
Definition: completion_queue.h:162
#define GRPC_OVERRIDE
Definition: config.h:77
Definition: server_builder.h:54
::google::protobuf::Message Message
Definition: config_protobuf.h:60