summaryrefslogtreecommitdiff
path: root/grpc/spm-cpp-include/grpcpp/impl/codegen/server_callback.h
diff options
context:
space:
mode:
Diffstat (limited to 'grpc/spm-cpp-include/grpcpp/impl/codegen/server_callback.h')
-rw-r--r--grpc/spm-cpp-include/grpcpp/impl/codegen/server_callback.h55
1 files changed, 33 insertions, 22 deletions
diff --git a/grpc/spm-cpp-include/grpcpp/impl/codegen/server_callback.h b/grpc/spm-cpp-include/grpcpp/impl/codegen/server_callback.h
index 9dda984a..3ccabdbb 100644
--- a/grpc/spm-cpp-include/grpcpp/impl/codegen/server_callback.h
+++ b/grpc/spm-cpp-include/grpcpp/impl/codegen/server_callback.h
@@ -29,6 +29,7 @@
#include <grpcpp/impl/codegen/core_codegen_interface.h>
#include <grpcpp/impl/codegen/message_allocator.h>
#include <grpcpp/impl/codegen/status.h>
+#include <grpcpp/impl/codegen/sync.h>
namespace grpc {
@@ -256,7 +257,12 @@ class ServerCallbackReaderWriter : public internal::ServerCallbackCall {
// by the user, returned as the output parameter of the method handler for a
// callback method. 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.
+// reactions that it cares about. The reaction methods 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 ServerBidiReactor is the interface for a bidirectional streaming RPC.
template <class Request, class Response>
@@ -273,7 +279,7 @@ class ServerBidiReactor : public internal::ServerReactor {
/// Send any initial metadata stored in the RPC context. If not invoked,
/// any initial metadata will be passed along with the first Write or the
/// Finish (if there are no writes).
- void StartSendInitialMetadata() {
+ void StartSendInitialMetadata() ABSL_LOCKS_EXCLUDED(stream_mu_) {
ServerCallbackReaderWriter<Request, Response>* stream =
stream_.load(std::memory_order_acquire);
if (stream == nullptr) {
@@ -291,7 +297,7 @@ class ServerBidiReactor : public internal::ServerReactor {
///
/// \param[out] req Where to eventually store the read message. Valid when
/// the library calls OnReadDone
- void StartRead(Request* req) {
+ void StartRead(Request* req) ABSL_LOCKS_EXCLUDED(stream_mu_) {
ServerCallbackReaderWriter<Request, Response>* stream =
stream_.load(std::memory_order_acquire);
if (stream == nullptr) {
@@ -320,7 +326,8 @@ class ServerBidiReactor : public internal::ServerReactor {
/// ownership but the caller must ensure that the message is
/// not deleted or modified until OnWriteDone is called.
/// \param[in] options The WriteOptions to use for writing this message
- void StartWrite(const Response* resp, ::grpc::WriteOptions options) {
+ void StartWrite(const Response* resp, ::grpc::WriteOptions options)
+ ABSL_LOCKS_EXCLUDED(stream_mu_) {
ServerCallbackReaderWriter<Request, Response>* stream =
stream_.load(std::memory_order_acquire);
if (stream == nullptr) {
@@ -349,7 +356,7 @@ class ServerBidiReactor : public internal::ServerReactor {
/// \param[in] options The WriteOptions to use for writing this message
/// \param[in] s The status outcome of this RPC
void StartWriteAndFinish(const Response* resp, ::grpc::WriteOptions options,
- ::grpc::Status s) {
+ ::grpc::Status s) ABSL_LOCKS_EXCLUDED(stream_mu_) {
ServerCallbackReaderWriter<Request, Response>* stream =
stream_.load(std::memory_order_acquire);
if (stream == nullptr) {
@@ -384,7 +391,7 @@ class ServerBidiReactor : public internal::ServerReactor {
/// cancelled.
///
/// \param[in] s The status outcome of this RPC
- void Finish(::grpc::Status s) {
+ void Finish(::grpc::Status s) ABSL_LOCKS_EXCLUDED(stream_mu_) {
ServerCallbackReaderWriter<Request, Response>* stream =
stream_.load(std::memory_order_acquire);
if (stream == nullptr) {
@@ -476,7 +483,7 @@ class ServerBidiReactor : public internal::ServerReactor {
::grpc::WriteOptions write_options_wanted;
::grpc::Status status_wanted;
};
- PreBindBacklog backlog_ /* GUARDED_BY(stream_mu_) */;
+ PreBindBacklog backlog_ ABSL_GUARDED_BY(stream_mu_);
};
/// \a ServerReadReactor is the interface for a client-streaming RPC.
@@ -487,7 +494,7 @@ class ServerReadReactor : public internal::ServerReactor {
~ServerReadReactor() override = default;
/// The following operation initiations are exactly like ServerBidiReactor.
- void StartSendInitialMetadata() {
+ void StartSendInitialMetadata() ABSL_LOCKS_EXCLUDED(reader_mu_) {
ServerCallbackReader<Request>* reader =
reader_.load(std::memory_order_acquire);
if (reader == nullptr) {
@@ -500,7 +507,7 @@ class ServerReadReactor : public internal::ServerReactor {
}
reader->SendInitialMetadata();
}
- void StartRead(Request* req) {
+ void StartRead(Request* req) ABSL_LOCKS_EXCLUDED(reader_mu_) {
ServerCallbackReader<Request>* reader =
reader_.load(std::memory_order_acquire);
if (reader == nullptr) {
@@ -513,7 +520,7 @@ class ServerReadReactor : public internal::ServerReactor {
}
reader->Read(req);
}
- void Finish(::grpc::Status s) {
+ void Finish(::grpc::Status s) ABSL_LOCKS_EXCLUDED(reader_mu_) {
ServerCallbackReader<Request>* reader =
reader_.load(std::memory_order_acquire);
if (reader == nullptr) {
@@ -539,7 +546,8 @@ class ServerReadReactor : public internal::ServerReactor {
// May be overridden by internal implementation details. This is not a public
// customization point.
- virtual void InternalBindReader(ServerCallbackReader<Request>* reader) {
+ virtual void InternalBindReader(ServerCallbackReader<Request>* reader)
+ ABSL_LOCKS_EXCLUDED(reader_mu_) {
grpc::internal::MutexLock l(&reader_mu_);
if (GPR_UNLIKELY(backlog_.send_initial_metadata_wanted)) {
@@ -563,7 +571,7 @@ class ServerReadReactor : public internal::ServerReactor {
Request* read_wanted = nullptr;
::grpc::Status status_wanted;
};
- PreBindBacklog backlog_ /* GUARDED_BY(reader_mu_) */;
+ PreBindBacklog backlog_ ABSL_GUARDED_BY(reader_mu_);
};
/// \a ServerWriteReactor is the interface for a server-streaming RPC.
@@ -574,7 +582,7 @@ class ServerWriteReactor : public internal::ServerReactor {
~ServerWriteReactor() override = default;
/// The following operation initiations are exactly like ServerBidiReactor.
- void StartSendInitialMetadata() {
+ void StartSendInitialMetadata() ABSL_LOCKS_EXCLUDED(writer_mu_) {
ServerCallbackWriter<Response>* writer =
writer_.load(std::memory_order_acquire);
if (writer == nullptr) {
@@ -590,7 +598,8 @@ class ServerWriteReactor : public internal::ServerReactor {
void StartWrite(const Response* resp) {
StartWrite(resp, ::grpc::WriteOptions());
}
- void StartWrite(const Response* resp, ::grpc::WriteOptions options) {
+ void StartWrite(const Response* resp, ::grpc::WriteOptions options)
+ ABSL_LOCKS_EXCLUDED(writer_mu_) {
ServerCallbackWriter<Response>* writer =
writer_.load(std::memory_order_acquire);
if (writer == nullptr) {
@@ -605,7 +614,7 @@ class ServerWriteReactor : public internal::ServerReactor {
writer->Write(resp, options);
}
void StartWriteAndFinish(const Response* resp, ::grpc::WriteOptions options,
- ::grpc::Status s) {
+ ::grpc::Status s) ABSL_LOCKS_EXCLUDED(writer_mu_) {
ServerCallbackWriter<Response>* writer =
writer_.load(std::memory_order_acquire);
if (writer == nullptr) {
@@ -624,7 +633,7 @@ class ServerWriteReactor : public internal::ServerReactor {
void StartWriteLast(const Response* resp, ::grpc::WriteOptions options) {
StartWrite(resp, options.set_last_message());
}
- void Finish(::grpc::Status s) {
+ void Finish(::grpc::Status s) ABSL_LOCKS_EXCLUDED(writer_mu_) {
ServerCallbackWriter<Response>* writer =
writer_.load(std::memory_order_acquire);
if (writer == nullptr) {
@@ -649,7 +658,8 @@ class ServerWriteReactor : public internal::ServerReactor {
friend class ServerCallbackWriter<Response>;
// May be overridden by internal implementation details. This is not a public
// customization point.
- virtual void InternalBindWriter(ServerCallbackWriter<Response>* writer) {
+ virtual void InternalBindWriter(ServerCallbackWriter<Response>* writer)
+ ABSL_LOCKS_EXCLUDED(writer_mu_) {
grpc::internal::MutexLock l(&writer_mu_);
if (GPR_UNLIKELY(backlog_.send_initial_metadata_wanted)) {
@@ -682,7 +692,7 @@ class ServerWriteReactor : public internal::ServerReactor {
::grpc::WriteOptions write_options_wanted;
::grpc::Status status_wanted;
};
- PreBindBacklog backlog_ /* GUARDED_BY(writer_mu_) */;
+ PreBindBacklog backlog_ ABSL_GUARDED_BY(writer_mu_);
};
class ServerUnaryReactor : public internal::ServerReactor {
@@ -691,7 +701,7 @@ class ServerUnaryReactor : public internal::ServerReactor {
~ServerUnaryReactor() override = default;
/// StartSendInitialMetadata is exactly like ServerBidiReactor.
- void StartSendInitialMetadata() {
+ void StartSendInitialMetadata() ABSL_LOCKS_EXCLUDED(call_mu_) {
ServerCallbackUnary* call = call_.load(std::memory_order_acquire);
if (call == nullptr) {
grpc::internal::MutexLock l(&call_mu_);
@@ -706,7 +716,7 @@ class ServerUnaryReactor : public internal::ServerReactor {
/// Finish is similar to ServerBidiReactor except for one detail.
/// If the status is non-OK, any message will not be sent. Instead,
/// the client will only receive the status and any trailing metadata.
- void Finish(::grpc::Status s) {
+ void Finish(::grpc::Status s) ABSL_LOCKS_EXCLUDED(call_mu_) {
ServerCallbackUnary* call = call_.load(std::memory_order_acquire);
if (call == nullptr) {
grpc::internal::MutexLock l(&call_mu_);
@@ -729,7 +739,8 @@ class ServerUnaryReactor : public internal::ServerReactor {
friend class ServerCallbackUnary;
// May be overridden by internal implementation details. This is not a public
// customization point.
- virtual void InternalBindCall(ServerCallbackUnary* call) {
+ virtual void InternalBindCall(ServerCallbackUnary* call)
+ ABSL_LOCKS_EXCLUDED(call_mu_) {
grpc::internal::MutexLock l(&call_mu_);
if (GPR_UNLIKELY(backlog_.send_initial_metadata_wanted)) {
@@ -749,7 +760,7 @@ class ServerUnaryReactor : public internal::ServerReactor {
bool finish_wanted = false;
::grpc::Status status_wanted;
};
- PreBindBacklog backlog_ /* GUARDED_BY(call_mu_) */;
+ PreBindBacklog backlog_ ABSL_GUARDED_BY(call_mu_);
};
namespace internal {