Fixing errors and minor bugs

pull/13058/head
Yash Tibrewal 8 years ago
parent a13a8c0f3e
commit eaf67dbdf6
  1. 20
      src/core/lib/iomgr/exec_ctx.cc
  2. 20
      src/core/lib/iomgr/exec_ctx.h
  3. 2
      src/core/lib/iomgr/pollset_uv.cc
  4. 2
      src/core/lib/iomgr/pollset_windows.cc
  5. 2
      test/core/util/test_tcp_server.cc
  6. 8
      test/cpp/microbenchmarks/bm_pollset.cc

@ -108,6 +108,13 @@ namespace grpc_core {
thread_local ExecCtx* ExecCtx::exec_ctx_ = nullptr;
#endif
void ExecCtx::GlobalInit(void) {
g_start_time = gpr_now(GPR_CLOCK_MONOTONIC);
#ifdef GPR_PTHREAD_TLS
gpr_tls_init(&exec_ctx_);
#endif
}
bool ExecCtx::Flush() {
bool did_something = 0;
GPR_TIMER_BEGIN("grpc_exec_ctx_flush", 0);
@ -131,19 +138,6 @@ bool ExecCtx::Flush() {
return did_something;
}
void ExecCtx::GlobalInit(void) {
g_start_time = gpr_now(GPR_CLOCK_MONOTONIC);
#ifdef GPR_PTHREAD_TLS
gpr_tls_init(&exec_ctx_);
#endif
}
void ExecCtx::GlobalShutdown(void) {
#ifdef GPR_PTHREAD_TLS
gpr_tls_destroy(&exec_ctx_);
#endif
}
grpc_millis ExecCtx::Now() {
if (!now_is_valid_) {
now_ = timespec_to_atm_round_down(gpr_now(GPR_CLOCK_MONOTONIC));

@ -47,6 +47,12 @@ typedef struct grpc_combiner grpc_combiner;
should be given to not delete said call/channel from this exec_ctx */
#define GRPC_EXEC_CTX_FLAG_THREAD_RESOURCE_LOOP 2
extern grpc_closure_scheduler* grpc_schedule_on_exec_ctx;
gpr_timespec grpc_millis_to_timespec(grpc_millis millis, gpr_clock_type clock);
grpc_millis grpc_timespec_to_millis_round_down(gpr_timespec timespec);
grpc_millis grpc_timespec_to_millis_round_up(gpr_timespec timespec);
namespace grpc_core {
/** Execution context.
* A bag of data that collects information along a callstack.
@ -164,7 +170,11 @@ on outside context */
static void GlobalInit(void);
/** Global shutdown for ExecCtx. Called by iomgr */
static void GlobalShutdown(void);
static void GlobalShutdown(void) {
#ifdef GPR_PTHREAD_TLS
gpr_tls_destroy(&exec_ctx_);
#endif
}
/** Gets pointer to current exec_ctx */
static ExecCtx* Get() {
@ -206,14 +216,6 @@ on outside context */
};
} // namespace grpc_core
extern grpc_closure_scheduler* grpc_schedule_on_exec_ctx;
gpr_timespec grpc_millis_to_timespec(grpc_millis millis, gpr_clock_type clock);
grpc_millis grpc_timespec_to_millis_round_down(gpr_timespec timespec);
grpc_millis grpc_timespec_to_millis_round_up(gpr_timespec timespec);
void grpc_exec_ctx_maybe_update_start_time();
#ifdef __cplusplus
}
#endif

@ -139,7 +139,7 @@ grpc_error* grpc_pollset_work(grpc_pollset* pollset,
uv_run(uv_default_loop(), UV_RUN_NOWAIT);
}
}
if (!grpc_closure_list_empty(exec_ctx->closure_list)) {
if (!grpc_closure_list_empty(*grpc_core::ExecCtx::Get()->closure_list())) {
grpc_core::ExecCtx::Get()->Flush();
}
gpr_mu_lock(&grpc_polling_mu);

@ -166,7 +166,7 @@ grpc_error* grpc_pollset_work(grpc_pollset* pollset,
pollset->kicked_without_pollers = 0;
}
done:
if (!grpc_closure_list_empty(exec_ctx->closure_list)) {
if (!grpc_closure_list_empty(*grpc_core::ExecCtx::Get()->closure_list())) {
gpr_mu_unlock(&grpc_polling_mu);
grpc_core::ExecCtx::Get()->Flush();
gpr_mu_lock(&grpc_polling_mu);

@ -106,7 +106,7 @@ void test_tcp_server_destroy(test_tcp_server* server) {
grpc_pollset_shutdown(server->pollset,
GRPC_CLOSURE_CREATE(finish_pollset, server->pollset,
grpc_schedule_on_exec_ctx));
grpc_core::ExecCtx::Get()->Flush();
gpr_free(server->pollset);
grpc_shutdown();
}

@ -62,7 +62,7 @@ static void BM_CreateDestroyPollset(benchmark::State& state) {
gpr_mu_unlock(mu);
grpc_core::ExecCtx::Get()->Flush();
}
grpc_core::ExecCtx::Get()->Flush();
gpr_free(ps);
track_counters.Finish(state);
}
@ -124,7 +124,7 @@ static void BM_PollEmptyPollset(benchmark::State& state) {
grpc_schedule_on_exec_ctx);
grpc_pollset_shutdown(ps, &shutdown_ps_closure);
gpr_mu_unlock(mu);
grpc_core::ExecCtx::Get()->Flush();
gpr_free(ps);
track_counters.Finish(state);
}
@ -152,7 +152,7 @@ static void BM_PollAddFd(benchmark::State& state) {
gpr_mu_lock(mu);
grpc_pollset_shutdown(ps, &shutdown_ps_closure);
gpr_mu_unlock(mu);
grpc_core::ExecCtx::Get()->Flush();
gpr_free(ps);
track_counters.Finish(state);
}
@ -248,7 +248,7 @@ static void BM_SingleThreadPollOneFd(benchmark::State& state) {
grpc_schedule_on_exec_ctx);
grpc_pollset_shutdown(ps, &shutdown_ps_closure);
gpr_mu_unlock(mu);
grpc_core::ExecCtx::Get()->Flush();
grpc_wakeup_fd_destroy(&wakeup_fd);
gpr_free(ps);
track_counters.Finish(state);

Loading…
Cancel
Save