diff options
author | Craig Tiller <ctiller@google.com> | 2015-10-06 11:33:14 -0700 |
---|---|---|
committer | Craig Tiller <ctiller@google.com> | 2015-10-06 11:33:14 -0700 |
commit | d49e3a1e6bc8f269257d7879f132bda1bd36b0a4 (patch) | |
tree | e66ea70084135eb57cee9e9c9797d0de991c42c7 /src/core/iomgr | |
parent | d0a00003d6123a45842ac6df842abcbdb6ed612f (diff) |
Add commentary
Diffstat (limited to 'src/core/iomgr')
-rw-r--r-- | src/core/iomgr/fd_posix.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/src/core/iomgr/fd_posix.c b/src/core/iomgr/fd_posix.c index 7ae8d6efa5..231bc988a8 100644 --- a/src/core/iomgr/fd_posix.c +++ b/src/core/iomgr/fd_posix.c @@ -242,8 +242,10 @@ void grpc_fd_unref(grpc_fd *fd) { unref_by(fd, 2); } static void notify_on_locked(grpc_exec_ctx *exec_ctx, grpc_fd *fd, grpc_closure **st, grpc_closure *closure) { if (*st == CLOSURE_NOT_READY) { + /* not ready ==> switch to a waiting state by setting the closure */ *st = closure; } else if (*st == CLOSURE_READY) { + /* already ready ==> queue the closure to run immediately */ *st = CLOSURE_NOT_READY; grpc_exec_ctx_enqueue(exec_ctx, closure, !fd->shutdown); maybe_wake_one_watcher_locked(fd); @@ -260,12 +262,14 @@ static void notify_on_locked(grpc_exec_ctx *exec_ctx, grpc_fd *fd, static int set_ready_locked(grpc_exec_ctx *exec_ctx, grpc_fd *fd, grpc_closure **st) { if (*st == CLOSURE_READY) { - /* duplicate ready, ignore */ + /* duplicate ready ==> ignore */ return 0; } else if (*st == CLOSURE_NOT_READY) { + /* not ready, and not waiting ==> flag ready */ *st = CLOSURE_READY; return 0; } else { + /* waiting ==> queue closure */ grpc_exec_ctx_enqueue(exec_ctx, *st, !fd->shutdown); *st = CLOSURE_NOT_READY; return 1; |