MCPcopy Create free account
hub / github.com/acl-dev/acl / event_loop

Function event_loop

lib_acl/src/event/events_kernel_thr.c:366–503  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

364}
365
366static void event_loop(ACL_EVENT *eventp)
367{
368 const char *myname = "event_loop";
369 EVENT_KERNEL_THR *event_thr = (EVENT_KERNEL_THR *) eventp;
370 int nready;
371 acl_int64 delay, when;
372 ACL_EVENT_FDTABLE *fdp;
373 EVENT_BUFFER *bp;
374
375 delay = eventp->delay_sec * 1000000 + eventp->delay_usec;
376 if (delay <= DELAY_MIN) {
377 delay = DELAY_MIN;
378 }
379
380 SET_TIME(eventp->present);
381
382 THREAD_LOCK(&event_thr->event.tm_mutex);
383
384 when = event_timer_when(eventp);
385
386 /*
387 * Find out when the next timer would go off. Timer requests are sorted.
388 * If any timer is scheduled, adjust the delay appropriately.
389 */
390 if (when >= 0) {
391 acl_int64 n = when - eventp->present;
392 if (n <= 0) {
393 delay = 0;
394 } else if (n < delay) {
395 delay = n;
396 }
397 }
398
399 THREAD_UNLOCK(&event_thr->event.tm_mutex);
400
401 eventp->ready_cnt = 0;
402
403 if (eventp->present - eventp->last_check >= eventp->check_inter) {
404 eventp->last_check = eventp->present;
405
406 THREAD_LOCK(&event_thr->event.tb_mutex);
407
408 if (event_thr_prepare(eventp) == 0) {
409 THREAD_UNLOCK(&event_thr->event.tb_mutex);
410
411 if (eventp->ready_cnt == 0) {
412 acl_doze(delay > DELAY_MIN ? (int) delay / 1000 : 1);
413 }
414
415 nready = 0;
416 goto TAG_DONE;
417 }
418
419 THREAD_UNLOCK(&event_thr->event.tb_mutex);
420
421 if (eventp->ready_cnt > 0) {
422 delay = 0;
423 }

Callers

nothing calls this directly

Calls 9

event_timer_whenFunction · 0.85
event_thr_prepareFunction · 0.85
acl_dozeFunction · 0.85
acl_last_errorFunction · 0.85
acl_msg_fatalFunction · 0.85
acl_last_serrorFunction · 0.85
acl_fdmap_ctxFunction · 0.85
event_timer_trigger_thrFunction · 0.85
event_thr_fireFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…