|
|
|
@ -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 { |
|
|
|
|
|
|
|
|
@ -278,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) { |
|
|
|
@ -296,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) { |
|
|
|
@ -325,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) { |
|
|
|
@ -354,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) { |
|
|
|
@ -389,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) { |
|
|
|
@ -481,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.
|
|
|
|
@ -492,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) { |
|
|
|
@ -505,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) { |
|
|
|
@ -518,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) { |
|
|
|
@ -544,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)) { |
|
|
|
@ -568,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.
|
|
|
|
@ -579,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) { |
|
|
|
@ -595,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) { |
|
|
|
@ -610,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) { |
|
|
|
@ -629,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) { |
|
|
|
@ -654,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)) { |
|
|
|
@ -687,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 { |
|
|
|
@ -696,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_); |
|
|
|
@ -711,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_); |
|
|
|
@ -734,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)) { |
|
|
|
@ -754,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 { |
|
|
|
|