mirror of
https://gitlab.nic.cz/labs/bird.git
synced 2024-12-22 17:51:53 +00:00
Flush deferred calls directly after the loop finished its one run
This commit is contained in:
parent
865bab6237
commit
1e77e6e1b2
@ -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 first, send the actual event to the local thread */
|
||||||
if (local_deferred.last == &local_deferred.first)
|
if (local_deferred.last == &local_deferred.first)
|
||||||
ev_send_this_thread(&local_deferred.e);
|
ev_send_defer(&local_deferred.e);
|
||||||
|
|
||||||
/* Add to list */
|
/* Add to list */
|
||||||
a->next = NULL;
|
a->next = NULL;
|
||||||
|
@ -19,6 +19,9 @@ extern struct birdloop main_birdloop;
|
|||||||
/* Currently running birdloop */
|
/* Currently running birdloop */
|
||||||
extern _Thread_local struct birdloop *this_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 */
|
/* Check that the task has enough time to do a bit more */
|
||||||
bool task_still_in_limit(void);
|
bool task_still_in_limit(void);
|
||||||
bool task_before_halftime(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_stop_self(struct birdloop *loop, void (*stopped)(void *data), void *data);
|
||||||
void birdloop_free(struct birdloop *loop);
|
void birdloop_free(struct birdloop *loop);
|
||||||
|
|
||||||
/* Run this event in this thread's priority event list */
|
/* Run this event in the running loop's priority event list to run asap */
|
||||||
void ev_send_this_thread(event *e);
|
void ev_send_defer(event *e);
|
||||||
|
|
||||||
/* Get birdloop's time heap */
|
/* Get birdloop's time heap */
|
||||||
struct timeloop *birdloop_time_loop(struct birdloop *loop);
|
struct timeloop *birdloop_time_loop(struct birdloop *loop);
|
||||||
|
@ -1543,6 +1543,10 @@ birdloop_run(void *_loop)
|
|||||||
/* Process socket RX */
|
/* Process socket RX */
|
||||||
sockets_fire(loop, 1, 0);
|
sockets_fire(loop, 1, 0);
|
||||||
|
|
||||||
|
/* Flush deferred events */
|
||||||
|
while (ev_run_list(&loop->defer_list))
|
||||||
|
repeat++;
|
||||||
|
|
||||||
/* Check end time */
|
/* Check end time */
|
||||||
} while (repeat && task_still_in_limit());
|
} while (repeat && task_still_in_limit());
|
||||||
|
|
||||||
@ -1750,10 +1754,10 @@ birdloop_yield(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
ev_send_this_thread(event *e)
|
ev_send_defer(event *e)
|
||||||
{
|
{
|
||||||
if (this_thread == &main_thread)
|
if (this_thread == &main_thread)
|
||||||
ev_send_loop(&main_birdloop, e);
|
ev_send_loop(&main_birdloop, e);
|
||||||
else
|
else
|
||||||
ev_send(&this_thread->priority_events, e);
|
ev_send(&this_birdloop->defer_list, e);
|
||||||
}
|
}
|
||||||
|
@ -48,6 +48,7 @@ struct birdloop
|
|||||||
|
|
||||||
struct timeloop time;
|
struct timeloop time;
|
||||||
event_list event_list;
|
event_list event_list;
|
||||||
|
event_list defer_list;
|
||||||
list sock_list;
|
list sock_list;
|
||||||
struct birdsock *sock_active;
|
struct birdsock *sock_active;
|
||||||
int sock_num;
|
int sock_num;
|
||||||
|
Loading…
Reference in New Issue
Block a user