diff --git a/src/core/iomgr/fd_posix.c b/src/core/iomgr/fd_posix.c index 33d90872c30319416f4c1783b9ed074a2a6e1a4e..5bbf171c6d4f0cc776b9dee34fa0ab6dc907162b 100644 --- a/src/core/iomgr/fd_posix.c +++ b/src/core/iomgr/fd_posix.c @@ -302,7 +302,8 @@ void grpc_fd_shutdown(grpc_fd *fd) { set_ready_locked(&fd->writest, &fd->shutdown_closures[0], &ncb); gpr_mu_unlock(&fd->set_state_mu); GPR_ASSERT(ncb <= 2); - process_callbacks(fd->shutdown_closures[0], ncb, 0, 0); + process_callbacks(fd->shutdown_closures[0], ncb, 0 /* GPR_FALSE */, + 0 /* GPR_FALSE */); } void grpc_fd_notify_on_read(grpc_fd *fd, grpc_iomgr_closure *closure) { diff --git a/src/core/iomgr/iomgr.c b/src/core/iomgr/iomgr.c index 85867b6edfe20d68441eedeab1dba578b4db2fb2..b983a89daa87d33dc500548c051644a11448cf8d 100644 --- a/src/core/iomgr/iomgr.c +++ b/src/core/iomgr/iomgr.c @@ -163,7 +163,6 @@ void grpc_iomgr_closure_init(grpc_iomgr_closure *closure, grpc_iomgr_cb_func cb, void *cb_arg) { closure->cb = cb; closure->cb_arg = cb_arg; - closure->success = -1; /* uninitialized */ closure->next = NULL; } @@ -182,7 +181,7 @@ void grpc_iomgr_add_delayed_callback(grpc_iomgr_closure *closure, int success) { void grpc_iomgr_add_callback(grpc_iomgr_closure *closure) { - grpc_iomgr_add_delayed_callback(closure, 1); + grpc_iomgr_add_delayed_callback(closure, 1 /* GPR_TRUE */); } diff --git a/src/core/iomgr/iomgr.h b/src/core/iomgr/iomgr.h index 913f83f80e7502536ad40b817716f7b015e5b56c..a10e481e481d238bfa0103f878773d3140a8d7c2 100644 --- a/src/core/iomgr/iomgr.h +++ b/src/core/iomgr/iomgr.h @@ -34,29 +34,43 @@ #ifndef GRPC_INTERNAL_CORE_IOMGR_IOMGR_H #define GRPC_INTERNAL_CORE_IOMGR_IOMGR_H -/* gRPC Callback definition */ +/** gRPC Callback definition. + * + * \param arg Arbitrary input. + * \param success An indication on the state of the iomgr. On false, cleanup + * actions should be taken (eg, shutdown). */ typedef void (*grpc_iomgr_cb_func)(void *arg, int success); +/** A closure over a grpc_iomgr_cb_func. */ typedef struct grpc_iomgr_closure { + /** Bound callback. */ grpc_iomgr_cb_func cb; + + /** Arguments to be passed to "cb". */ void *cb_arg; + + /** Internal. A boolean indication to "cb" on the state of the iomgr. + * For instance, closures created during a shutdown would have this field set + * to false. */ int success; - struct grpc_iomgr_closure *next; /** Do not touch */ + + /**< Internal. Do not touch */ + struct grpc_iomgr_closure *next; } grpc_iomgr_closure; +/** Initializes \a closure with \a cb and \a cb_arg. */ void grpc_iomgr_closure_init(grpc_iomgr_closure *closure, grpc_iomgr_cb_func cb, void *cb_arg); -/* TODO(dgq): get rid of the managed_closure concept. */ -void grpc_iomgr_managed_closure_init(grpc_iomgr_closure *manager, - grpc_iomgr_cb_func managed_cb, - void *managed_cb_arg); - +/** Initializes the iomgr. */ void grpc_iomgr_init(void); + +/** Signals the intention to shutdown the iomgr. */ void grpc_iomgr_shutdown(void); -/* This function is called from within a callback or from anywhere else - and causes the invocation of a callback at some point in the future */ +/** Registers a closure to be invoked at some point in the future. + * + * Can be called from within a callback or from anywhere else */ void grpc_iomgr_add_callback(grpc_iomgr_closure *closure); #endif /* GRPC_INTERNAL_CORE_IOMGR_IOMGR_H */ diff --git a/src/core/iomgr/pollset_windows.c b/src/core/iomgr/pollset_windows.c index 5af0685f9d97818dee8255028af3db176155174f..b1f4c09a2cf07217b18df61f4fb11a45be854e6e 100644 --- a/src/core/iomgr/pollset_windows.c +++ b/src/core/iomgr/pollset_windows.c @@ -66,15 +66,15 @@ int grpc_pollset_work(grpc_pollset *pollset, gpr_timespec deadline) { gpr_timespec now; now = gpr_now(); if (gpr_time_cmp(now, deadline) > 0) { - return 0; + return 0 /* GPR_FALSE */; } - if (grpc_maybe_call_delayed_callbacks(NULL, 1)) { - return 1; + if (grpc_maybe_call_delayed_callbacks(NULL, 1 /* GPR_TRUE */)) { + return 1 /* GPR_TRUE */; } if (grpc_alarm_check(NULL, now, &deadline)) { - return 1; + return 1 /* GPR_TRUE */; } - return 0; + return 0 /* GPR_FALSE */; } void grpc_pollset_kick(grpc_pollset *p) { }