diff options
author | dvshkurko <dvshkurko@yandex-team.ru> | 2022-02-10 16:45:52 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:45:52 +0300 |
commit | c768a99151e47c3a4bb7b92c514d256abd301c4d (patch) | |
tree | 1a2c5ffcf89eb53ecd79dbc9bc0a195c27404d0c /contrib/libs/grpc/src/cpp/server/server_context.cc | |
parent | 321ee9bce31ec6e238be26dbcbe539cffa2c3309 (diff) | |
download | ydb-c768a99151e47c3a4bb7b92c514d256abd301c4d.tar.gz |
Restoring authorship annotation for <dvshkurko@yandex-team.ru>. Commit 2 of 2.
Diffstat (limited to 'contrib/libs/grpc/src/cpp/server/server_context.cc')
-rw-r--r-- | contrib/libs/grpc/src/cpp/server/server_context.cc | 84 |
1 files changed, 42 insertions, 42 deletions
diff --git a/contrib/libs/grpc/src/cpp/server/server_context.cc b/contrib/libs/grpc/src/cpp/server/server_context.cc index 4a4181d39f..458ac20d87 100644 --- a/contrib/libs/grpc/src/cpp/server/server_context.cc +++ b/contrib/libs/grpc/src/cpp/server/server_context.cc @@ -28,18 +28,18 @@ #include <grpc/support/log.h> #include <grpcpp/impl/call.h> #include <grpcpp/impl/codegen/completion_queue.h> -#include <grpcpp/support/server_callback.h> +#include <grpcpp/support/server_callback.h> #include <grpcpp/support/time.h> -#include "src/core/lib/gprpp/ref_counted.h" -#include "src/core/lib/gprpp/sync.h" +#include "src/core/lib/gprpp/ref_counted.h" +#include "src/core/lib/gprpp/sync.h" #include "src/core/lib/surface/call.h" namespace grpc { // CompletionOp -class ServerContextBase::CompletionOp final +class ServerContextBase::CompletionOp final : public internal::CallOpSetInterface { public: // initial refs: one in the server context, one in the cq @@ -47,7 +47,7 @@ class ServerContextBase::CompletionOp final CompletionOp(internal::Call* call, ::grpc::internal::ServerCallbackCall* callback_controller) : call_(*call), - callback_controller_(callback_controller), + callback_controller_(callback_controller), has_tag_(false), tag_(nullptr), core_cq_tag_(this), @@ -73,10 +73,10 @@ class ServerContextBase::CompletionOp final // This should always be arena allocated in the call, so override delete. // But this class is not trivially destructible, so must actually call delete // before allowing the arena to be freed - static void operator delete(void* /*ptr*/, std::size_t size) { - // Use size to avoid unused-parameter warning since assert seems to be - // compiled out and treated as unused in some gcc optimized versions. - (void)size; + static void operator delete(void* /*ptr*/, std::size_t size) { + // Use size to avoid unused-parameter warning since assert seems to be + // compiled out and treated as unused in some gcc optimized versions. + (void)size; assert(size == sizeof(CompletionOp)); } @@ -110,7 +110,7 @@ class ServerContextBase::CompletionOp final // RPC. This should set hijacking state for each of the ops. void SetHijackingState() override { /* Servers don't allow hijacking */ - GPR_ASSERT(false); + GPR_ASSERT(false); } /* Should be called after interceptors are done running */ @@ -122,17 +122,17 @@ class ServerContextBase::CompletionOp final done_intercepting_ = true; if (!has_tag_) { /* We don't have a tag to return. */ - Unref(); + Unref(); return; } /* Start a dummy op so that we can return the tag */ - GPR_ASSERT(grpc_call_start_batch(call_.call(), nullptr, 0, core_cq_tag_, - nullptr) == GRPC_CALL_OK); + GPR_ASSERT(grpc_call_start_batch(call_.call(), nullptr, 0, core_cq_tag_, + nullptr) == GRPC_CALL_OK); } private: bool CheckCancelledNoPluck() { - grpc_core::MutexLock lock(&mu_); + grpc_core::MutexLock lock(&mu_); return finalized_ ? (cancelled_ != 0) : false; } @@ -141,16 +141,16 @@ class ServerContextBase::CompletionOp final bool has_tag_; void* tag_; void* core_cq_tag_; - grpc_core::RefCount refs_; - grpc_core::Mutex mu_; + grpc_core::RefCount refs_; + grpc_core::Mutex mu_; bool finalized_; int cancelled_; // This is an int (not bool) because it is passed to core bool done_intercepting_; internal::InterceptorBatchMethodsImpl interceptor_methods_; }; -void ServerContextBase::CompletionOp::Unref() { - if (refs_.Unref()) { +void ServerContextBase::CompletionOp::Unref() { + if (refs_.Unref()) { grpc_call* call = call_.call(); delete this; grpc_call_unref(call); @@ -166,14 +166,14 @@ void ServerContextBase::CompletionOp::FillOps(internal::Call* call) { interceptor_methods_.SetCall(&call_); interceptor_methods_.SetReverse(); interceptor_methods_.SetCallOpSetInterface(this); - // The following call_start_batch is internally-generated so no need for an - // explanatory log on failure. - GPR_ASSERT(grpc_call_start_batch(call->call(), &ops, 1, core_cq_tag_, - nullptr) == GRPC_CALL_OK); + // The following call_start_batch is internally-generated so no need for an + // explanatory log on failure. + GPR_ASSERT(grpc_call_start_batch(call->call(), &ops, 1, core_cq_tag_, + nullptr) == GRPC_CALL_OK); /* No interceptors to run here */ } -bool ServerContextBase::CompletionOp::FinalizeResult(void** tag, bool* status) { +bool ServerContextBase::CompletionOp::FinalizeResult(void** tag, bool* status) { // Decide whether to call the cancel callback within the lock bool call_cancel; @@ -201,8 +201,8 @@ bool ServerContextBase::CompletionOp::FinalizeResult(void** tag, bool* status) { // Release the lock since we may call a callback and interceptors. } - if (call_cancel && callback_controller_ != nullptr) { - callback_controller_->MaybeCallOnCancel(); + if (call_cancel && callback_controller_ != nullptr) { + callback_controller_->MaybeCallOnCancel(); } /* Add interception point and run through interceptors */ interceptor_methods_.AddInterceptionHookPoint( @@ -213,26 +213,26 @@ bool ServerContextBase::CompletionOp::FinalizeResult(void** tag, bool* status) { if (has_tag) { *tag = tag_; } - Unref(); + Unref(); return has_tag; } // There are interceptors to be run. Return false for now. return false; } -// ServerContextBase body +// ServerContextBase body ServerContextBase::ServerContextBase() : deadline_(gpr_inf_future(GPR_CLOCK_REALTIME)) {} -ServerContextBase::ServerContextBase(gpr_timespec deadline, +ServerContextBase::ServerContextBase(gpr_timespec deadline, grpc_metadata_array* arr) : deadline_(deadline) { std::swap(*client_metadata_.arr(), *arr); } -void ServerContextBase::BindDeadlineAndMetadata(gpr_timespec deadline, - grpc_metadata_array* arr) { +void ServerContextBase::BindDeadlineAndMetadata(gpr_timespec deadline, + grpc_metadata_array* arr) { deadline_ = deadline; std::swap(*client_metadata_.arr(), *arr); } @@ -244,9 +244,9 @@ ServerContextBase::~ServerContextBase() { if (rpc_info_) { rpc_info_->Unref(); } - if (default_reactor_used_.load(std::memory_order_relaxed)) { + if (default_reactor_used_.load(std::memory_order_relaxed)) { reinterpret_cast<Reactor*>(&default_reactor_)->~Reactor(); - } + } } ServerContextBase::CallWrapper::~CallWrapper() { @@ -257,7 +257,7 @@ ServerContextBase::CallWrapper::~CallWrapper() { } } -void ServerContextBase::BeginCompletionOp( +void ServerContextBase::BeginCompletionOp( internal::Call* call, std::function<void(bool)> callback, ::grpc::internal::ServerCallbackCall* callback_controller) { GPR_ASSERT(!completion_op_); @@ -267,10 +267,10 @@ void ServerContextBase::BeginCompletionOp( grpc_call_ref(call->call()); completion_op_ = new (grpc_call_arena_alloc(call->call(), sizeof(CompletionOp))) - CompletionOp(call, callback_controller); - if (callback_controller != nullptr) { - completion_tag_.Set(call->call(), std::move(callback), completion_op_, - true); + CompletionOp(call, callback_controller); + if (callback_controller != nullptr) { + completion_tag_.Set(call->call(), std::move(callback), completion_op_, + true); completion_op_->set_core_cq_tag(&completion_tag_); completion_op_->set_tag(completion_op_); } else if (has_notify_when_done_tag_) { @@ -293,7 +293,7 @@ void ServerContextBase::AddTrailingMetadata(const TString& key, trailing_metadata_.insert(std::make_pair(key, value)); } -void ServerContextBase::TryCancel() const { +void ServerContextBase::TryCancel() const { internal::CancelInterceptorBatchMethods cancel_methods; if (rpc_info_) { for (size_t i = 0; i < rpc_info_->interceptors_.size(); i++) { @@ -308,7 +308,7 @@ void ServerContextBase::TryCancel() const { } } -bool ServerContextBase::IsCancelled() const { +bool ServerContextBase::IsCancelled() const { if (completion_tag_) { // When using callback API, this result is always valid. return completion_op_->CheckCancelledAsync(); @@ -322,7 +322,7 @@ bool ServerContextBase::IsCancelled() const { } } -void ServerContextBase::set_compression_algorithm( +void ServerContextBase::set_compression_algorithm( grpc_compression_algorithm algorithm) { compression_algorithm_ = algorithm; const char* algorithm_name = nullptr; @@ -345,12 +345,12 @@ TString ServerContextBase::peer() const { return peer; } -const struct census_context* ServerContextBase::census_context() const { +const struct census_context* ServerContextBase::census_context() const { return call_.call == nullptr ? nullptr : grpc_census_call_get_context(call_.call); } -void ServerContextBase::SetLoadReportingCosts( +void ServerContextBase::SetLoadReportingCosts( const std::vector<TString>& cost_data) { if (call_.call == nullptr) return; for (const auto& cost_datum : cost_data) { |