|
|
|
@ -159,33 +159,37 @@ class ClientAsyncReaderInterface |
|
|
|
|
: public internal::ClientAsyncStreamingInterface, |
|
|
|
|
public internal::AsyncReaderInterface<R> {}; |
|
|
|
|
|
|
|
|
|
namespace internal { |
|
|
|
|
template <class R> |
|
|
|
|
class ClientAsyncReaderFactory { |
|
|
|
|
public: |
|
|
|
|
/// Create a stream object.
|
|
|
|
|
/// Write the first request out if \a start is set.
|
|
|
|
|
/// \a tag will be notified on \a cq when the call has been started and
|
|
|
|
|
/// \a request has been written out. If \a start is not set, \a tag must be
|
|
|
|
|
/// nullptr and the actual call must be initiated by StartCall
|
|
|
|
|
/// Note that \a context will be used to fill in custom initial metadata
|
|
|
|
|
/// used to send to the server when starting the call.
|
|
|
|
|
template <class W> |
|
|
|
|
static ClientAsyncReader<R>* Create(ChannelInterface* channel, |
|
|
|
|
CompletionQueue* cq, |
|
|
|
|
const ::grpc::internal::RpcMethod& method, |
|
|
|
|
ClientContext* context, const W& request, |
|
|
|
|
bool start, void* tag) { |
|
|
|
|
::grpc::internal::Call call = channel->CreateCall(method, context, cq); |
|
|
|
|
return new (g_core_codegen_interface->grpc_call_arena_alloc( |
|
|
|
|
call.call(), sizeof(ClientAsyncReader<R>))) |
|
|
|
|
ClientAsyncReader<R>(call, context, request, start, tag); |
|
|
|
|
} |
|
|
|
|
}; |
|
|
|
|
} // namespace internal
|
|
|
|
|
|
|
|
|
|
/// Async client-side API for doing server-streaming RPCs,
|
|
|
|
|
/// where the incoming message stream coming from the server has
|
|
|
|
|
/// messages of type \a R.
|
|
|
|
|
template <class R> |
|
|
|
|
class ClientAsyncReader final : public ClientAsyncReaderInterface<R> { |
|
|
|
|
public: |
|
|
|
|
struct internal { |
|
|
|
|
/// Create a stream object.
|
|
|
|
|
/// Write the first request out if \a start is set.
|
|
|
|
|
/// \a tag will be notified on \a cq when the call has been started and
|
|
|
|
|
/// \a request has been written out. If \a start is not set, \a tag must be
|
|
|
|
|
/// nullptr and the actual call must be initiated by StartCall
|
|
|
|
|
/// Note that \a context will be used to fill in custom initial metadata
|
|
|
|
|
/// used to send to the server when starting the call.
|
|
|
|
|
template <class W> |
|
|
|
|
static ClientAsyncReader* Create(ChannelInterface* channel, |
|
|
|
|
CompletionQueue* cq, |
|
|
|
|
const ::grpc::internal::RpcMethod& method, |
|
|
|
|
ClientContext* context, const W& request, |
|
|
|
|
bool start, void* tag) { |
|
|
|
|
::grpc::internal::Call call = channel->CreateCall(method, context, cq); |
|
|
|
|
return new (g_core_codegen_interface->grpc_call_arena_alloc( |
|
|
|
|
call.call(), sizeof(ClientAsyncReader))) |
|
|
|
|
ClientAsyncReader(call, context, request, start, tag); |
|
|
|
|
} |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
// always allocated against a call arena, no memory free required
|
|
|
|
|
static void operator delete(void* ptr, std::size_t size) { |
|
|
|
|
assert(size == sizeof(ClientAsyncReader)); |
|
|
|
@ -240,6 +244,7 @@ class ClientAsyncReader final : public ClientAsyncReaderInterface<R> { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private: |
|
|
|
|
friend class internal::ClientAsyncReaderFactory<R>; |
|
|
|
|
template <class W> |
|
|
|
|
ClientAsyncReader(::grpc::internal::Call call, ClientContext* context, |
|
|
|
|
const W& request, bool start, void* tag) |
|
|
|
@ -291,37 +296,41 @@ class ClientAsyncWriterInterface |
|
|
|
|
virtual void WritesDone(void* tag) = 0; |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
namespace internal { |
|
|
|
|
template <class W> |
|
|
|
|
class ClientAsyncWriterFactory { |
|
|
|
|
public: |
|
|
|
|
/// Create a stream object.
|
|
|
|
|
/// Start the RPC if \a start is set
|
|
|
|
|
/// \a tag will be notified on \a cq when the call has been started (i.e.
|
|
|
|
|
/// intitial metadata sent) and \a request has been written out.
|
|
|
|
|
/// If \a start is not set, \a tag must be nullptr and the actual call
|
|
|
|
|
/// must be initiated by StartCall
|
|
|
|
|
/// Note that \a context will be used to fill in custom initial metadata
|
|
|
|
|
/// used to send to the server when starting the call.
|
|
|
|
|
/// \a response will be filled in with the single expected response
|
|
|
|
|
/// message from the server upon a successful call to the \a Finish
|
|
|
|
|
/// method of this instance.
|
|
|
|
|
template <class R> |
|
|
|
|
static ClientAsyncWriter<W>* Create(ChannelInterface* channel, |
|
|
|
|
CompletionQueue* cq, |
|
|
|
|
const ::grpc::internal::RpcMethod& method, |
|
|
|
|
ClientContext* context, R* response, |
|
|
|
|
bool start, void* tag) { |
|
|
|
|
::grpc::internal::Call call = channel->CreateCall(method, context, cq); |
|
|
|
|
return new (g_core_codegen_interface->grpc_call_arena_alloc( |
|
|
|
|
call.call(), sizeof(ClientAsyncWriter<W>))) |
|
|
|
|
ClientAsyncWriter<W>(call, context, response, start, tag); |
|
|
|
|
} |
|
|
|
|
}; |
|
|
|
|
} // namespace internal
|
|
|
|
|
|
|
|
|
|
/// Async API on the client side for doing client-streaming RPCs,
|
|
|
|
|
/// where the outgoing message stream going to the server contains
|
|
|
|
|
/// messages of type \a W.
|
|
|
|
|
template <class W> |
|
|
|
|
class ClientAsyncWriter final : public ClientAsyncWriterInterface<W> { |
|
|
|
|
public: |
|
|
|
|
struct internal { |
|
|
|
|
/// Create a stream object.
|
|
|
|
|
/// Start the RPC if \a start is set
|
|
|
|
|
/// \a tag will be notified on \a cq when the call has been started (i.e.
|
|
|
|
|
/// intitial metadata sent) and \a request has been written out.
|
|
|
|
|
/// If \a start is not set, \a tag must be nullptr and the actual call
|
|
|
|
|
/// must be initiated by StartCall
|
|
|
|
|
/// Note that \a context will be used to fill in custom initial metadata
|
|
|
|
|
/// used to send to the server when starting the call.
|
|
|
|
|
/// \a response will be filled in with the single expected response
|
|
|
|
|
/// message from the server upon a successful call to the \a Finish
|
|
|
|
|
/// method of this instance.
|
|
|
|
|
template <class R> |
|
|
|
|
static ClientAsyncWriter* Create(ChannelInterface* channel, |
|
|
|
|
CompletionQueue* cq, |
|
|
|
|
const ::grpc::internal::RpcMethod& method, |
|
|
|
|
ClientContext* context, R* response, |
|
|
|
|
bool start, void* tag) { |
|
|
|
|
::grpc::internal::Call call = channel->CreateCall(method, context, cq); |
|
|
|
|
return new (g_core_codegen_interface->grpc_call_arena_alloc( |
|
|
|
|
call.call(), sizeof(ClientAsyncWriter))) |
|
|
|
|
ClientAsyncWriter(call, context, response, start, tag); |
|
|
|
|
} |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
// always allocated against a call arena, no memory free required
|
|
|
|
|
static void operator delete(void* ptr, std::size_t size) { |
|
|
|
|
assert(size == sizeof(ClientAsyncWriter)); |
|
|
|
@ -394,6 +403,7 @@ class ClientAsyncWriter final : public ClientAsyncWriterInterface<W> { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private: |
|
|
|
|
friend class internal::ClientAsyncWriterFactory<W>; |
|
|
|
|
template <class R> |
|
|
|
|
ClientAsyncWriter(::grpc::internal::Call call, ClientContext* context, |
|
|
|
|
R* response, bool start, void* tag) |
|
|
|
@ -449,6 +459,30 @@ class ClientAsyncReaderWriterInterface |
|
|
|
|
virtual void WritesDone(void* tag) = 0; |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
namespace internal { |
|
|
|
|
template <class W, class R> |
|
|
|
|
class ClientAsyncReaderWriterFactory { |
|
|
|
|
public: |
|
|
|
|
/// Create a stream object.
|
|
|
|
|
/// Start the RPC request if \a start is set.
|
|
|
|
|
/// \a tag will be notified on \a cq when the call has been started (i.e.
|
|
|
|
|
/// intitial metadata sent). If \a start is not set, \a tag must be
|
|
|
|
|
/// nullptr and the actual call must be initiated by StartCall
|
|
|
|
|
/// Note that \a context will be used to fill in custom initial metadata
|
|
|
|
|
/// used to send to the server when starting the call.
|
|
|
|
|
static ClientAsyncReaderWriter<W, R>* Create( |
|
|
|
|
ChannelInterface* channel, CompletionQueue* cq, |
|
|
|
|
const ::grpc::internal::RpcMethod& method, ClientContext* context, |
|
|
|
|
bool start, void* tag) { |
|
|
|
|
::grpc::internal::Call call = channel->CreateCall(method, context, cq); |
|
|
|
|
|
|
|
|
|
return new (g_core_codegen_interface->grpc_call_arena_alloc( |
|
|
|
|
call.call(), sizeof(ClientAsyncReaderWriter<W, R>))) |
|
|
|
|
ClientAsyncReaderWriter<W, R>(call, context, start, tag); |
|
|
|
|
} |
|
|
|
|
}; |
|
|
|
|
} // namespace internal
|
|
|
|
|
|
|
|
|
|
/// Async client-side interface for bi-directional streaming,
|
|
|
|
|
/// where the outgoing message stream going to the server
|
|
|
|
|
/// has messages of type \a W, and the incoming message stream coming
|
|
|
|
@ -457,26 +491,6 @@ template <class W, class R> |
|
|
|
|
class ClientAsyncReaderWriter final |
|
|
|
|
: public ClientAsyncReaderWriterInterface<W, R> { |
|
|
|
|
public: |
|
|
|
|
struct internal { |
|
|
|
|
/// Create a stream object.
|
|
|
|
|
/// Start the RPC request if \a start is set.
|
|
|
|
|
/// \a tag will be notified on \a cq when the call has been started (i.e.
|
|
|
|
|
/// intitial metadata sent). If \a start is not set, \a tag must be
|
|
|
|
|
/// nullptr and the actual call must be initiated by StartCall
|
|
|
|
|
/// Note that \a context will be used to fill in custom initial metadata
|
|
|
|
|
/// used to send to the server when starting the call.
|
|
|
|
|
static ClientAsyncReaderWriter* Create( |
|
|
|
|
ChannelInterface* channel, CompletionQueue* cq, |
|
|
|
|
const ::grpc::internal::RpcMethod& method, ClientContext* context, |
|
|
|
|
bool start, void* tag) { |
|
|
|
|
::grpc::internal::Call call = channel->CreateCall(method, context, cq); |
|
|
|
|
|
|
|
|
|
return new (g_core_codegen_interface->grpc_call_arena_alloc( |
|
|
|
|
call.call(), sizeof(ClientAsyncReaderWriter))) |
|
|
|
|
ClientAsyncReaderWriter(call, context, start, tag); |
|
|
|
|
} |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
// always allocated against a call arena, no memory free required
|
|
|
|
|
static void operator delete(void* ptr, std::size_t size) { |
|
|
|
|
assert(size == sizeof(ClientAsyncReaderWriter)); |
|
|
|
@ -556,6 +570,7 @@ class ClientAsyncReaderWriter final |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private: |
|
|
|
|
friend class internal::ClientAsyncReaderWriterFactory<W, R>; |
|
|
|
|
ClientAsyncReaderWriter(::grpc::internal::Call call, ClientContext* context, |
|
|
|
|
bool start, void* tag) |
|
|
|
|
: context_(context), call_(call), started_(start) { |
|
|
|
|