diff options
Diffstat (limited to 'sysdep/unix/io-loop.h')
-rw-r--r-- | sysdep/unix/io-loop.h | 84 |
1 files changed, 60 insertions, 24 deletions
diff --git a/sysdep/unix/io-loop.h b/sysdep/unix/io-loop.h index 1727637a..2b0b7ebf 100644 --- a/sysdep/unix/io-loop.h +++ b/sysdep/unix/io-loop.h @@ -7,52 +7,88 @@ #ifndef _BIRD_SYSDEP_UNIX_IO_LOOP_H_ #define _BIRD_SYSDEP_UNIX_IO_LOOP_H_ -#include "nest/bird.h" +#include "lib/rcu.h" -#include "lib/lists.h" -#include "lib/event.h" -#include "lib/timer.h" +#include <pthread.h> -struct free_pages +struct pipe { - list list; /* List of empty pages */ - event *cleanup; /* Event to call when number of pages is outside bounds */ - u16 min, max; /* Minimal and maximal number of free pages kept */ - uint cnt; /* Number of empty pages */ + int fd[2]; }; +struct pfd { + BUFFER(struct pollfd) pfd; + BUFFER(struct birdloop *) loop; +}; + +void sockets_prepare(struct birdloop *, struct pfd *); +void socket_changed(struct birdsock *); + +void pipe_new(struct pipe *); +void pipe_pollin(struct pipe *, struct pfd *); +void pipe_drain(struct pipe *); +void pipe_kick(struct pipe *); + struct birdloop { - resource r; + node n; + + event event; + timer timer; pool *pool; - pool *parent; struct timeloop time; event_list event_list; list sock_list; - uint sock_num; + struct birdsock *sock_active; + int sock_num; + uint sock_changed; - BUFFER(sock *) poll_sk; - BUFFER(struct pollfd) poll_fd; - u8 poll_changed; + uint ping_pending; - _Atomic u32 ping_sent; - int wakeup_fds[2]; - - uint links; - - struct free_pages pages; + _Atomic u32 thread_transition; +#define LTT_PING 1 +#define LTT_MOVE 2 + _Atomic u32 flags; + struct birdloop_flag_handler *flag_handler; void (*stopped)(void *data); void *stop_data; struct birdloop *prev_loop; + + struct bird_thread *thread; + + u64 total_time_spent_ns; }; -extern _Thread_local struct birdloop *birdloop_current; +struct bird_thread +{ + node n; -void init_pages(struct birdloop *loop); -void flush_pages(struct birdloop *loop); + struct pipe wakeup; + event_list priority_events; + + struct birdloop *meta; + + pthread_t thread_id; + pthread_attr_t thread_attr; + + struct rcu_thread rcu; + + list loops; + struct birdloop_pickup_group *group; + pool *pool; + struct pfd *pfd; + + event cleanup_event; + + int sock_changed; + uint loop_count; + + u64 max_latency_ns; + u64 max_loop_time_ns; +}; #endif |