Added some comments.

pull/1758/head
David Garcia Quintas 10 years ago
parent 8b8cce05d7
commit 1c762bd945
  1. 3
      src/core/iomgr/fd_posix.c
  2. 3
      src/core/iomgr/iomgr.c
  3. 32
      src/core/iomgr/iomgr.h
  4. 10
      src/core/iomgr/pollset_windows.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) {

@ -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 */);
}

@ -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 */

@ -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) { }

Loading…
Cancel
Save