|
|
@ -45,6 +45,7 @@ |
|
|
|
#include "src/cpp/thread_manager/thread_manager.h" |
|
|
|
#include "src/cpp/thread_manager/thread_manager.h" |
|
|
|
|
|
|
|
|
|
|
|
namespace grpc { |
|
|
|
namespace grpc { |
|
|
|
|
|
|
|
namespace { |
|
|
|
|
|
|
|
|
|
|
|
class DefaultGlobalCallbacks final : public Server::GlobalCallbacks { |
|
|
|
class DefaultGlobalCallbacks final : public Server::GlobalCallbacks { |
|
|
|
public: |
|
|
|
public: |
|
|
@ -53,16 +54,29 @@ class DefaultGlobalCallbacks final : public Server::GlobalCallbacks { |
|
|
|
void PostSynchronousRequest(ServerContext* context) override {} |
|
|
|
void PostSynchronousRequest(ServerContext* context) override {} |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
static std::shared_ptr<Server::GlobalCallbacks> g_callbacks = nullptr; |
|
|
|
std::shared_ptr<Server::GlobalCallbacks> g_callbacks = nullptr; |
|
|
|
static gpr_once g_once_init_callbacks = GPR_ONCE_INIT; |
|
|
|
gpr_once g_once_init_callbacks = GPR_ONCE_INIT; |
|
|
|
|
|
|
|
|
|
|
|
static void InitGlobalCallbacks() { |
|
|
|
void InitGlobalCallbacks() { |
|
|
|
if (!g_callbacks) { |
|
|
|
if (!g_callbacks) { |
|
|
|
g_callbacks.reset(new DefaultGlobalCallbacks()); |
|
|
|
g_callbacks.reset(new DefaultGlobalCallbacks()); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
class Server::UnimplementedAsyncRequestContext { |
|
|
|
class ShutdownTag : public internal::CompletionQueueTag { |
|
|
|
|
|
|
|
public: |
|
|
|
|
|
|
|
bool FinalizeResult(void** tag, bool* status) { return false; } |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class DummyTag : public internal::CompletionQueueTag { |
|
|
|
|
|
|
|
public: |
|
|
|
|
|
|
|
bool FinalizeResult(void** tag, bool* status) { |
|
|
|
|
|
|
|
*status = true; |
|
|
|
|
|
|
|
return true; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class UnimplementedAsyncRequestContext { |
|
|
|
protected: |
|
|
|
protected: |
|
|
|
UnimplementedAsyncRequestContext() : generic_stream_(&server_context_) {} |
|
|
|
UnimplementedAsyncRequestContext() : generic_stream_(&server_context_) {} |
|
|
|
|
|
|
|
|
|
|
@ -70,8 +84,14 @@ class Server::UnimplementedAsyncRequestContext { |
|
|
|
GenericServerAsyncReaderWriter generic_stream_; |
|
|
|
GenericServerAsyncReaderWriter generic_stream_; |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} // namespace
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// Use private inheritance rather than composition only to establish order
|
|
|
|
|
|
|
|
/// of construction, since the public base class should be constructed after the
|
|
|
|
|
|
|
|
/// elements belonging to the private base class are constructed. This is not
|
|
|
|
|
|
|
|
/// possible using true composition.
|
|
|
|
class Server::UnimplementedAsyncRequest final |
|
|
|
class Server::UnimplementedAsyncRequest final |
|
|
|
: public UnimplementedAsyncRequestContext, |
|
|
|
: private UnimplementedAsyncRequestContext, |
|
|
|
public GenericAsyncRequest { |
|
|
|
public GenericAsyncRequest { |
|
|
|
public: |
|
|
|
public: |
|
|
|
UnimplementedAsyncRequest(Server* server, ServerCompletionQueue* cq) |
|
|
|
UnimplementedAsyncRequest(Server* server, ServerCompletionQueue* cq) |
|
|
@ -90,38 +110,27 @@ class Server::UnimplementedAsyncRequest final |
|
|
|
ServerCompletionQueue* const cq_; |
|
|
|
ServerCompletionQueue* const cq_; |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
typedef internal::SneakyCallOpSet<internal::CallOpSendInitialMetadata, |
|
|
|
/// UnimplementedAsyncResponse should not post user-visible completions to the
|
|
|
|
internal::CallOpServerSendStatus> |
|
|
|
/// C++ completion queue, but is generated as a CQ event by the core
|
|
|
|
UnimplementedAsyncResponseOp; |
|
|
|
|
|
|
|
class Server::UnimplementedAsyncResponse final |
|
|
|
class Server::UnimplementedAsyncResponse final |
|
|
|
: public UnimplementedAsyncResponseOp { |
|
|
|
: public internal::CallOpSet<internal::CallOpSendInitialMetadata, |
|
|
|
|
|
|
|
internal::CallOpServerSendStatus> { |
|
|
|
public: |
|
|
|
public: |
|
|
|
UnimplementedAsyncResponse(UnimplementedAsyncRequest* request); |
|
|
|
UnimplementedAsyncResponse(UnimplementedAsyncRequest* request); |
|
|
|
~UnimplementedAsyncResponse() { delete request_; } |
|
|
|
~UnimplementedAsyncResponse() { delete request_; } |
|
|
|
|
|
|
|
|
|
|
|
bool FinalizeResult(void** tag, bool* status) override { |
|
|
|
bool FinalizeResult(void** tag, bool* status) override { |
|
|
|
bool r = UnimplementedAsyncResponseOp::FinalizeResult(tag, status); |
|
|
|
internal::CallOpSet< |
|
|
|
|
|
|
|
internal::CallOpSendInitialMetadata, |
|
|
|
|
|
|
|
internal::CallOpServerSendStatus>::FinalizeResult(tag, status); |
|
|
|
delete this; |
|
|
|
delete this; |
|
|
|
return r; |
|
|
|
return false; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private: |
|
|
|
private: |
|
|
|
UnimplementedAsyncRequest* const request_; |
|
|
|
UnimplementedAsyncRequest* const request_; |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
class ShutdownTag : public internal::CompletionQueueTag { |
|
|
|
|
|
|
|
public: |
|
|
|
|
|
|
|
bool FinalizeResult(void** tag, bool* status) { return false; } |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class DummyTag : public internal::CompletionQueueTag { |
|
|
|
|
|
|
|
public: |
|
|
|
|
|
|
|
bool FinalizeResult(void** tag, bool* status) { |
|
|
|
|
|
|
|
*status = true; |
|
|
|
|
|
|
|
return true; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class Server::SyncRequest final : public internal::CompletionQueueTag { |
|
|
|
class Server::SyncRequest final : public internal::CompletionQueueTag { |
|
|
|
public: |
|
|
|
public: |
|
|
|
SyncRequest(internal::RpcServiceMethod* method, void* tag) |
|
|
|
SyncRequest(internal::RpcServiceMethod* method, void* tag) |
|
|
|