Skip to content

Commit

Permalink
Avalanching operations on completion queue should be private, not API
Browse files Browse the repository at this point in the history
  • Loading branch information
vjpai committed Nov 14, 2017
1 parent 3810749 commit 2cb57e5
Showing 1 changed file with 17 additions and 15 deletions.
32 changes: 17 additions & 15 deletions include/grpc++/impl/codegen/completion_queue.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ class CompletionQueue;
class Server;
class ServerBuilder;
class ServerContext;
class ServerInterface;

namespace internal {
class CompletionQueueTag;
Expand Down Expand Up @@ -187,21 +188,6 @@ class CompletionQueue : private GrpcLibraryCodegen {
/// owership is performed.
grpc_completion_queue* cq() { return cq_; }

/// Manage state of avalanching operations : completion queue tags that
/// trigger other completion queue operations. The underlying core completion
/// queue should not really shutdown until all avalanching operations have
/// been finalized. Note that we maintain the requirement that an avalanche
/// registration must take place before CQ shutdown (which must be maintained
/// elsehwere)
void InitialAvalanching() {
gpr_atm_rel_store(&avalanches_in_flight_, static_cast<gpr_atm>(1));
}
void RegisterAvalanching() {
gpr_atm_no_barrier_fetch_add(&avalanches_in_flight_,
static_cast<gpr_atm>(1));
}
void CompleteAvalanching();

protected:
/// Private constructor of CompletionQueue only visible to friend classes
CompletionQueue(const grpc_completion_queue_attributes& attributes) {
Expand Down Expand Up @@ -238,6 +224,7 @@ class CompletionQueue : private GrpcLibraryCodegen {
friend class ::grpc::internal::UnknownMethodHandler;
friend class ::grpc::Server;
friend class ::grpc::ServerContext;
friend class ::grpc::ServerInterface;
template <class InputMessage, class OutputMessage>
friend class ::grpc::internal::BlockingUnaryCallImpl;

Expand Down Expand Up @@ -309,6 +296,21 @@ class CompletionQueue : private GrpcLibraryCodegen {
GPR_CODEGEN_ASSERT(!tag->FinalizeResult(&ignored, &ok));
}

/// Manage state of avalanching operations : completion queue tags that
/// trigger other completion queue operations. The underlying core completion
/// queue should not really shutdown until all avalanching operations have
/// been finalized. Note that we maintain the requirement that an avalanche
/// registration must take place before CQ shutdown (which must be maintained
/// elsehwere)
void InitialAvalanching() {
gpr_atm_rel_store(&avalanches_in_flight_, static_cast<gpr_atm>(1));
}
void RegisterAvalanching() {
gpr_atm_no_barrier_fetch_add(&avalanches_in_flight_,
static_cast<gpr_atm>(1));
}
void CompleteAvalanching();

grpc_completion_queue* cq_; // owned

gpr_atm avalanches_in_flight_;
Expand Down

0 comments on commit 2cb57e5

Please sign in to comment.