summaryrefslogtreecommitdiff
path: root/grpc/include/grpcpp/impl/codegen/client_callback.h
diff options
context:
space:
mode:
Diffstat (limited to 'grpc/include/grpcpp/impl/codegen/client_callback.h')
-rw-r--r--grpc/include/grpcpp/impl/codegen/client_callback.h40
1 files changed, 21 insertions, 19 deletions
diff --git a/grpc/include/grpcpp/impl/codegen/client_callback.h b/grpc/include/grpcpp/impl/codegen/client_callback.h
index 77bc885a..ba802909 100644
--- a/grpc/include/grpcpp/impl/codegen/client_callback.h
+++ b/grpc/include/grpcpp/impl/codegen/client_callback.h
@@ -27,6 +27,7 @@
#include <grpcpp/impl/codegen/config.h>
#include <grpcpp/impl/codegen/core_codegen_interface.h>
#include <grpcpp/impl/codegen/status.h>
+#include <grpcpp/impl/codegen/sync.h>
namespace grpc {
class Channel;
@@ -110,6 +111,8 @@ class CallbackUnaryCallImpl {
// Base class for public API classes.
class ClientReactor {
public:
+ virtual ~ClientReactor() = default;
+
/// Called by the library when all operations associated with this RPC have
/// completed and all Holds have been removed. OnDone provides the RPC status
/// outcome for both successful and failed RPCs. If it is never called on an
@@ -211,16 +214,19 @@ class ClientCallbackUnary {
// activated by calling StartCall, possibly after initiating StartRead,
// StartWrite, or AddHold operations on the streaming object. Note that none of
// the classes are pure; all reactions have a default empty reaction so that the
-// user class only needs to override those classes that it cares about.
+// user class only needs to override those reactions that it cares about.
// The reactor must be passed to the stub invocation before any of the below
-// operations can be called.
+// operations can be called and its reactions will be invoked by the library in
+// response to the completion of various operations. Reactions must not include
+// blocking operations (such as blocking I/O, starting synchronous RPCs, or
+// waiting on condition variables). Reactions may be invoked concurrently,
+// except that OnDone is called after all others (assuming proper API usage).
+// The reactor may not be deleted until OnDone is called.
/// \a ClientBidiReactor is the interface for a bidirectional streaming RPC.
template <class Request, class Response>
class ClientBidiReactor : public internal::ClientReactor {
public:
- virtual ~ClientBidiReactor() {}
-
/// Activate the RPC and initiate any reads or writes that have been Start'ed
/// before this call. All streaming RPCs issued by the client MUST have
/// StartCall invoked on them (even if they are canceled) as this call is the
@@ -357,8 +363,6 @@ class ClientBidiReactor : public internal::ClientReactor {
template <class Response>
class ClientReadReactor : public internal::ClientReactor {
public:
- virtual ~ClientReadReactor() {}
-
void StartCall() { reader_->StartCall(); }
void StartRead(Response* resp) { reader_->Read(resp); }
@@ -384,8 +388,6 @@ class ClientReadReactor : public internal::ClientReactor {
template <class Request>
class ClientWriteReactor : public internal::ClientReactor {
public:
- virtual ~ClientWriteReactor() {}
-
void StartCall() { writer_->StartCall(); }
void StartWrite(const Request* req) {
StartWrite(req, ::grpc::WriteOptions());
@@ -430,8 +432,6 @@ class ClientWriteReactor : public internal::ClientReactor {
/// initiation API among all the reactor flavors.
class ClientUnaryReactor : public internal::ClientReactor {
public:
- virtual ~ClientUnaryReactor() {}
-
void StartCall() { call_->StartCall(); }
void OnDone(const ::grpc::Status& /*s*/) override {}
virtual void OnReadInitialMetadataDone(bool /*ok*/) {}
@@ -473,7 +473,7 @@ class ClientCallbackReaderWriterImpl
// there are no tests catching the compiler warning.
static void operator delete(void*, void*) { GPR_CODEGEN_ASSERT(false); }
- void StartCall() override {
+ void StartCall() ABSL_LOCKS_EXCLUDED(start_mu_) override {
// This call initiates two batches, plus any backlog, each with a callback
// 1. Send initial metadata (unless corked) + recv initial metadata
// 2. Any read backlog
@@ -522,7 +522,8 @@ class ClientCallbackReaderWriterImpl
call_.PerformOps(&read_ops_);
}
- void Write(const Request* msg, ::grpc::WriteOptions options) override {
+ void Write(const Request* msg, ::grpc::WriteOptions options)
+ ABSL_LOCKS_EXCLUDED(start_mu_) override {
if (options.is_last_message()) {
options.set_buffer_hint();
write_ops_.ClientSendClose();
@@ -545,7 +546,7 @@ class ClientCallbackReaderWriterImpl
}
call_.PerformOps(&write_ops_);
}
- void WritesDone() override {
+ void WritesDone() ABSL_LOCKS_EXCLUDED(start_mu_) override {
writes_done_ops_.ClientSendClose();
writes_done_tag_.Set(
call_.call(),
@@ -686,7 +687,7 @@ class ClientCallbackReaderWriterImpl
bool writes_done_ops = false;
bool read_ops = false;
};
- StartCallBacklog backlog_ /* GUARDED_BY(start_mu_) */;
+ StartCallBacklog backlog_ ABSL_GUARDED_BY(start_mu_);
// Minimum of 3 callbacks to pre-register for start ops, StartCall, and finish
std::atomic<intptr_t> callbacks_outstanding_{3};
@@ -844,7 +845,7 @@ class ClientCallbackReaderImpl : public ClientCallbackReader<Response> {
struct StartCallBacklog {
bool read_ops = false;
};
- StartCallBacklog backlog_ /* GUARDED_BY(start_mu_) */;
+ StartCallBacklog backlog_ ABSL_GUARDED_BY(start_mu_);
// Minimum of 2 callbacks to pre-register for start and finish
std::atomic<intptr_t> callbacks_outstanding_{2};
@@ -885,7 +886,7 @@ class ClientCallbackWriterImpl : public ClientCallbackWriter<Request> {
// there are no tests catching the compiler warning.
static void operator delete(void*, void*) { GPR_CODEGEN_ASSERT(false); }
- void StartCall() override {
+ void StartCall() ABSL_LOCKS_EXCLUDED(start_mu_) override {
// This call initiates two batches, plus any backlog, each with a callback
// 1. Send initial metadata (unless corked) + recv initial metadata
// 2. Any backlog
@@ -917,7 +918,8 @@ class ClientCallbackWriterImpl : public ClientCallbackWriter<Request> {
this->MaybeFinish(/*from_reaction=*/false);
}
- void Write(const Request* msg, ::grpc::WriteOptions options) override {
+ void Write(const Request* msg, ::grpc::WriteOptions options)
+ ABSL_LOCKS_EXCLUDED(start_mu_) override {
if (GPR_UNLIKELY(options.is_last_message())) {
options.set_buffer_hint();
write_ops_.ClientSendClose();
@@ -942,7 +944,7 @@ class ClientCallbackWriterImpl : public ClientCallbackWriter<Request> {
call_.PerformOps(&write_ops_);
}
- void WritesDone() override {
+ void WritesDone() ABSL_LOCKS_EXCLUDED(start_mu_) override {
writes_done_ops_.ClientSendClose();
writes_done_tag_.Set(
call_.call(),
@@ -1071,7 +1073,7 @@ class ClientCallbackWriterImpl : public ClientCallbackWriter<Request> {
bool write_ops = false;
bool writes_done_ops = false;
};
- StartCallBacklog backlog_ /* GUARDED_BY(start_mu_) */;
+ StartCallBacklog backlog_ ABSL_GUARDED_BY(start_mu_);
// Minimum of 3 callbacks to pre-register for start ops, StartCall, and finish
std::atomic<intptr_t> callbacks_outstanding_{3};