diff options
author | yang-g <yangg@google.com> | 2017-11-20 13:49:54 -0800 |
---|---|---|
committer | yang-g <yangg@google.com> | 2017-11-20 13:49:54 -0800 |
commit | ed49fe5510780a96bf128bc6397f0d7d5394f669 (patch) | |
tree | 37c289b4220a819cce6b85fd4b3146bba5cd1664 /src/core | |
parent | 26521b38d235c9587ed391e285a3f5d34979df75 (diff) |
Resolve comments
Diffstat (limited to 'src/core')
-rw-r--r-- | src/core/lib/iomgr/ev_epoll1_linux.cc | 8 | ||||
-rw-r--r-- | src/core/lib/iomgr/ev_epollex_linux.cc | 8 | ||||
-rw-r--r-- | src/core/lib/iomgr/ev_epollsig_linux.cc | 8 | ||||
-rw-r--r-- | src/core/lib/iomgr/lockfree_event.cc | 6 | ||||
-rw-r--r-- | src/core/lib/iomgr/lockfree_event.h | 7 |
5 files changed, 20 insertions, 17 deletions
diff --git a/src/core/lib/iomgr/ev_epoll1_linux.cc b/src/core/lib/iomgr/ev_epoll1_linux.cc index dddd52c49f..8aada4e953 100644 --- a/src/core/lib/iomgr/ev_epoll1_linux.cc +++ b/src/core/lib/iomgr/ev_epoll1_linux.cc @@ -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; diff --git a/src/core/lib/iomgr/ev_epollex_linux.cc b/src/core/lib/iomgr/ev_epollex_linux.cc index d2192731bf..a6f069e294 100644 --- a/src/core/lib/iomgr/ev_epollex_linux.cc +++ b/src/core/lib/iomgr/ev_epollex_linux.cc @@ -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; diff --git a/src/core/lib/iomgr/ev_epollsig_linux.cc b/src/core/lib/iomgr/ev_epollsig_linux.cc index 25c0a93897..d51c665e8c 100644 --- a/src/core/lib/iomgr/ev_epollsig_linux.cc +++ b/src/core/lib/iomgr/ev_epollsig_linux.cc @@ -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; diff --git a/src/core/lib/iomgr/lockfree_event.cc b/src/core/lib/iomgr/lockfree_event.cc index 57a81fb5b2..edd997ff30 100644 --- a/src/core/lib/iomgr/lockfree_event.cc +++ b/src/core/lib/iomgr/lockfree_event.cc @@ -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_); diff --git a/src/core/lib/iomgr/lockfree_event.h b/src/core/lib/iomgr/lockfree_event.h index b9490f5458..aec67a3399 100644 --- a/src/core/lib/iomgr/lockfree_event.h +++ b/src/core/lib/iomgr/lockfree_event.h @@ -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; |