/* Check that the task has enough time to do a bit more */
_Bool task_still_in_limit(void);
+_Bool task_before_halftime(void);
#define MAYBE_DEFER_TASK(target, event, fmt, args...) do { \
if (!task_still_in_limit()) { \
if (rev & POLLIN)
/* Read just one packet and request repeat. */
- if ((s == loop->sock_active) && s->rx_hook)
- if (sk_read(s, rev))
+ while ((s == loop->sock_active) && s->rx_hook)
+ if (!task_before_halftime())
+ {
repeat++;
+ break;
+ }
+ else if (!sk_read(s, rev))
+ break;
if (s != loop->sock_active)
continue;
return ns_now() < account_last + this_thread->max_loop_time_ns;
}
+_Bool task_before_halftime(void)
+{
+ return ns_now() < account_last + this_thread->max_loop_time_ns / 2;
+}
+
/*
* Birdloop