struct tvec_base * glusterfs_ctx_tw_get(glusterfs_ctx_t *ctx) { struct gf_ctx_tw *ctx_tw = NULL; LOCK(&ctx->lock); { if (ctx->tw) { ctx_tw = GF_REF_GET(ctx->tw); } else { ctx_tw = GF_CALLOC(1, sizeof(struct gf_ctx_tw), gf_common_mt_tw_ctx); ctx_tw->timer_wheel = gf_tw_init_timers(); GF_REF_INIT(ctx_tw, glusterfs_ctx_tw_destroy); ctx->tw = ctx_tw; } } UNLOCK(&ctx->lock); return ctx_tw->timer_wheel; }
int glusterfs_global_timer_wheel_init (glusterfs_ctx_t *ctx) { ctx->timer_wheel = gf_tw_init_timers(); return ctx->timer_wheel ? 0 : -1; }