Resolve comments

pull/13454/head
yang-g 7 years ago
parent 26521b38d2
commit ed49fe5510
  1. 8
      src/core/lib/iomgr/ev_epoll1_linux.cc
  2. 8
      src/core/lib/iomgr/ev_epollex_linux.cc
  3. 8
      src/core/lib/iomgr/ev_epollsig_linux.cc
  4. 6
      src/core/lib/iomgr/lockfree_event.cc
  5. 7
      src/core/lib/iomgr/lockfree_event.h

@ -268,8 +268,8 @@ static grpc_fd* fd_create(int fd, const char* name) {
}
new_fd->fd = fd;
new_fd->read_closure->Init();
new_fd->write_closure->Init();
new_fd->read_closure->InitEvent();
new_fd->write_closure->InitEvent();
gpr_atm_no_barrier_store(&new_fd->read_notifier_pollset, (gpr_atm)NULL);
new_fd->freelist_next = nullptr;
@ -338,8 +338,8 @@ static void fd_orphan(grpc_exec_ctx* exec_ctx, grpc_fd* fd,
GRPC_CLOSURE_SCHED(exec_ctx, on_done, GRPC_ERROR_REF(error));
grpc_iomgr_unregister_object(&fd->iomgr_object);
fd->read_closure->Destroy();
fd->write_closure->Destroy();
fd->read_closure->DestroyEvent();
fd->write_closure->DestroyEvent();
gpr_mu_lock(&fd_freelist_mu);
fd->freelist_next = fd_freelist;

@ -288,8 +288,8 @@ static void fd_destroy(grpc_exec_ctx* exec_ctx, void* arg, grpc_error* error) {
fd->freelist_next = fd_freelist;
fd_freelist = fd;
fd->read_closure->Destroy();
fd->write_closure->Destroy();
fd->read_closure->DestroyEvent();
fd->write_closure->DestroyEvent();
gpr_mu_unlock(&fd_freelist_mu);
}
@ -351,8 +351,8 @@ static grpc_fd* fd_create(int fd, const char* name) {
new_fd->pollable_obj = nullptr;
gpr_atm_rel_store(&new_fd->refst, (gpr_atm)1);
new_fd->fd = fd;
new_fd->read_closure->Init();
new_fd->write_closure->Init();
new_fd->read_closure->InitEvent();
new_fd->write_closure->InitEvent();
gpr_atm_no_barrier_store(&new_fd->read_notifier_pollset, (gpr_atm)NULL);
new_fd->freelist_next = nullptr;

@ -767,8 +767,8 @@ static void unref_by(grpc_fd* fd, int n) {
fd_freelist = fd;
grpc_iomgr_unregister_object(&fd->iomgr_object);
fd->read_closure->Destroy();
fd->write_closure->Destroy();
fd->read_closure->DestroyEvent();
fd->write_closure->DestroyEvent();
gpr_mu_unlock(&fd_freelist_mu);
} else {
@ -835,8 +835,8 @@ static grpc_fd* fd_create(int fd, const char* name) {
gpr_atm_rel_store(&new_fd->refst, (gpr_atm)1);
new_fd->fd = fd;
new_fd->orphaned = false;
new_fd->read_closure->Init();
new_fd->write_closure->Init();
new_fd->read_closure->InitEvent();
new_fd->write_closure->InitEvent();
gpr_atm_no_barrier_store(&new_fd->read_notifier_pollset, (gpr_atm)NULL);
new_fd->freelist_next = nullptr;

@ -57,9 +57,9 @@ extern grpc_tracer_flag grpc_polling_trace;
namespace grpc_core {
LockfreeEvent::LockfreeEvent() { Init(); }
LockfreeEvent::LockfreeEvent() { InitEvent(); }
void LockfreeEvent::Init() {
void LockfreeEvent::InitEvent() {
/* Perform an atomic store to start the state machine.
Note carefully that LockfreeEvent *MAY* be used whilst in a destroyed
@ -69,7 +69,7 @@ void LockfreeEvent::Init() {
gpr_atm_no_barrier_store(&state_, kClosureNotReady);
}
void LockfreeEvent::Destroy() {
void LockfreeEvent::DestroyEvent() {
gpr_atm curr;
do {
curr = gpr_atm_no_barrier_load(&state_);

@ -34,8 +34,11 @@ class LockfreeEvent {
LockfreeEvent(const LockfreeEvent&) = delete;
LockfreeEvent& operator=(const LockfreeEvent&) = delete;
void Init();
void Destroy();
// These methods are used to initialize and destroy the internal state. These
// cannot be done in constructor and destructor because SetReady may be called
// when the event is destroyed and put in a freelist.
void InitEvent();
void DestroyEvent();
bool IsShutdown() const {
return (gpr_atm_no_barrier_load(&state_) & kShutdownBit) != 0;

Loading…
Cancel
Save