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

Function Cron_Run

src/cron/cron.c:187–215  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

185//------------------------------------------------------------------------------
186
187static void *Cron_Run
188(
189 void *arg
190) {
191 while(cron->alive) {
192 // execute due tasks
193 CRON_TASK *task = NULL;
194 while((task = CRON_Peek()) && CRON_TaskDue(task)) {
195 if(!CRON_RemoveCurrentTask(task)) {
196 // task is aborted
197 continue;
198 }
199
200 // perform and free task
201 CRON_PerformTask(task);
202 cron->current_task = NULL;
203 CRON_FreeTask(task);
204 }
205
206 // sleep
207 struct timespec timeout = (task) ? task->due : due_in_ms(1000);
208 pthread_mutex_lock(&cron->condv_mutex);
209 int res = pthread_cond_timedwait(&cron->condv, &cron->condv_mutex, &timeout);
210 ASSERT(res == 0 || res == ETIMEDOUT);
211 pthread_mutex_unlock(&cron->condv_mutex);
212 }
213
214 return NULL;
215}
216
217//------------------------------------------------------------------------------
218// User facing API

Callers

nothing calls this directly

Calls 6

CRON_PeekFunction · 0.85
CRON_TaskDueFunction · 0.85
CRON_RemoveCurrentTaskFunction · 0.85
CRON_PerformTaskFunction · 0.85
CRON_FreeTaskFunction · 0.85
due_in_msFunction · 0.85

Tested by

no test coverage detected