2013-09-16 21:57:40 +00:00
|
|
|
/*
|
|
|
|
* BIRD -- I/O and event loop
|
|
|
|
*
|
|
|
|
* Can be freely distributed and used under the terms of the GNU GPL.
|
|
|
|
*/
|
2013-09-10 10:09:36 +00:00
|
|
|
|
2021-06-19 18:50:18 +00:00
|
|
|
#ifndef _BIRD_SYSDEP_UNIX_IO_LOOP_H_
|
|
|
|
#define _BIRD_SYSDEP_UNIX_IO_LOOP_H_
|
2013-09-10 10:09:36 +00:00
|
|
|
|
2021-11-12 21:58:40 +00:00
|
|
|
#include "lib/rcu.h"
|
|
|
|
|
2023-01-21 22:42:02 +00:00
|
|
|
#include <pthread.h>
|
|
|
|
|
2022-09-20 15:01:50 +00:00
|
|
|
struct pipe
|
|
|
|
{
|
|
|
|
int fd[2];
|
|
|
|
};
|
|
|
|
|
|
|
|
void pipe_new(struct pipe *);
|
|
|
|
void pipe_pollin(struct pipe *, struct pollfd *);
|
|
|
|
void pipe_drain(struct pipe *);
|
|
|
|
void pipe_kick(struct pipe *);
|
|
|
|
|
2021-06-19 18:50:18 +00:00
|
|
|
struct birdloop
|
|
|
|
{
|
2023-01-19 09:49:47 +00:00
|
|
|
node n;
|
|
|
|
|
2021-06-19 18:50:18 +00:00
|
|
|
pool *pool;
|
2013-09-16 21:57:40 +00:00
|
|
|
|
2021-06-19 18:50:18 +00:00
|
|
|
struct timeloop time;
|
|
|
|
event_list event_list;
|
|
|
|
list sock_list;
|
2023-01-19 09:49:47 +00:00
|
|
|
int sock_num;
|
2013-09-10 10:09:36 +00:00
|
|
|
|
2022-07-28 17:49:03 +00:00
|
|
|
uint ping_pending;
|
2021-11-12 21:58:40 +00:00
|
|
|
|
2021-06-19 18:50:18 +00:00
|
|
|
uint links;
|
2013-11-19 21:33:48 +00:00
|
|
|
|
2022-09-12 08:24:55 +00:00
|
|
|
_Atomic u32 flags;
|
|
|
|
struct birdloop_flag_handler *flag_handler;
|
|
|
|
|
2021-06-19 18:50:18 +00:00
|
|
|
void (*stopped)(void *data);
|
|
|
|
void *stop_data;
|
2013-09-16 21:57:40 +00:00
|
|
|
|
2021-06-19 18:50:18 +00:00
|
|
|
struct birdloop *prev_loop;
|
2023-01-19 09:49:47 +00:00
|
|
|
|
|
|
|
struct bird_thread *thread;
|
|
|
|
struct pollfd *pfd;
|
|
|
|
|
|
|
|
u64 total_time_spent_ns;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct bird_thread
|
|
|
|
{
|
|
|
|
node n;
|
|
|
|
|
|
|
|
struct pollfd *pfd;
|
|
|
|
uint pfd_max;
|
|
|
|
|
|
|
|
_Atomic u32 ping_sent;
|
|
|
|
_Atomic u32 run_cleanup;
|
|
|
|
_Atomic u32 poll_changed;
|
|
|
|
|
|
|
|
struct pipe wakeup;
|
|
|
|
event_list priority_events;
|
|
|
|
|
|
|
|
pthread_t thread_id;
|
|
|
|
pthread_attr_t thread_attr;
|
|
|
|
|
|
|
|
struct rcu_thread rcu;
|
|
|
|
|
|
|
|
list loops;
|
|
|
|
pool *pool;
|
|
|
|
|
|
|
|
event cleanup_event;
|
2021-06-19 18:50:18 +00:00
|
|
|
};
|
2013-09-10 10:09:36 +00:00
|
|
|
|
2021-06-19 18:50:18 +00:00
|
|
|
#endif
|