mirror of
https://gitlab.nic.cz/labs/bird.git
synced 2024-11-09 20:58:44 +00:00
Flush deferred calls directly after the loop finished its one run
This commit is contained in:
parent
2bf28e790e
commit
e2a427fc30
@ -39,7 +39,7 @@ static inline void defer_call(struct deferred_call *call, size_t actual_size) {
|
||||
|
||||
/* If first, send the actual event to the local thread */
|
||||
if (local_deferred.last == &local_deferred.first)
|
||||
ev_send_this_thread(&local_deferred.e);
|
||||
ev_send_defer(&local_deferred.e);
|
||||
|
||||
/* Add to list */
|
||||
a->next = NULL;
|
||||
|
@ -19,6 +19,9 @@ extern struct birdloop main_birdloop;
|
||||
/* Currently running birdloop */
|
||||
extern _Thread_local struct birdloop *this_birdloop;
|
||||
|
||||
/* Lowest entered birdloop */
|
||||
extern _Thread_local struct birdloop *birdloop_current;
|
||||
|
||||
/* Check that the task has enough time to do a bit more */
|
||||
bool task_still_in_limit(void);
|
||||
bool task_before_halftime(void);
|
||||
@ -40,8 +43,8 @@ void birdloop_stop(struct birdloop *loop, void (*stopped)(void *data), void *dat
|
||||
void birdloop_stop_self(struct birdloop *loop, void (*stopped)(void *data), void *data);
|
||||
void birdloop_free(struct birdloop *loop);
|
||||
|
||||
/* Run this event in this thread's priority event list */
|
||||
void ev_send_this_thread(event *e);
|
||||
/* Run this event in the running loop's priority event list to run asap */
|
||||
void ev_send_defer(event *e);
|
||||
|
||||
/* Get birdloop's time heap */
|
||||
struct timeloop *birdloop_time_loop(struct birdloop *loop);
|
||||
|
@ -1541,6 +1541,10 @@ birdloop_run(void *_loop)
|
||||
/* Process socket RX */
|
||||
sockets_fire(loop, 1, 0);
|
||||
|
||||
/* Flush deferred events */
|
||||
while (ev_run_list(&loop->defer_list))
|
||||
repeat++;
|
||||
|
||||
/* Check end time */
|
||||
} while (repeat && task_still_in_limit());
|
||||
|
||||
@ -1748,10 +1752,10 @@ birdloop_yield(void)
|
||||
}
|
||||
|
||||
void
|
||||
ev_send_this_thread(event *e)
|
||||
ev_send_defer(event *e)
|
||||
{
|
||||
if (this_thread == &main_thread)
|
||||
ev_send_loop(&main_birdloop, e);
|
||||
else
|
||||
ev_send(&this_thread->priority_events, e);
|
||||
ev_send(&this_birdloop->defer_list, e);
|
||||
}
|
||||
|
@ -48,6 +48,7 @@ struct birdloop
|
||||
|
||||
struct timeloop time;
|
||||
event_list event_list;
|
||||
event_list defer_list;
|
||||
list sock_list;
|
||||
struct birdsock *sock_active;
|
||||
int sock_num;
|
||||
|
Loading…
Reference in New Issue
Block a user