MCPcopy Create free account
hub / github.com/RedisGraph/RedisGraph / CronTask_RecurringTask

Function CronTask_RecurringTask

src/cron/tasks.c:31–54  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

29}
30
31void CronTask_RecurringTask(void *pdata) {
32 ASSERT(pdata != NULL);
33 RecurringTaskCtx *current_ctx = (RecurringTaskCtx*)pdata;
34 bool speed_up = current_ctx->task(current_ctx->ctx);
35
36 bool info_enabled = false;
37 if(Config_Option_get(Config_CMD_INFO, &info_enabled) && info_enabled) {
38 RecurringTaskCtx *re_ctx = rm_malloc(sizeof(RecurringTaskCtx));
39 *re_ctx = *current_ctx;
40 re_ctx->ctx = re_ctx->new(re_ctx->ctx);
41
42 // determine next invocation
43 if(speed_up) {
44 // reduce delay, lower limit: 250ms
45 re_ctx->when = (re_ctx->min_interval + re_ctx->when) / 2;
46 } else {
47 // increase delay, upper limit: 3sec
48 re_ctx->when = (re_ctx->max_interval + re_ctx->when) / 2;
49 }
50
51 // re-add task to CRON
52 Cron_AddTask(re_ctx->when, CronTask_RecurringTask, CronTask_RecurringTaskFree, (void*)re_ctx);
53 }
54}
55
56void CronTask_AddStreamFinishedQueries() {
57 //--------------------------------------------------------------------------

Callers

nothing calls this directly

Calls 3

Config_Option_getFunction · 0.85
rm_mallocFunction · 0.85
Cron_AddTaskFunction · 0.85

Tested by

no test coverage detected