0
0
mirror of https://gitlab.nic.cz/labs/bird.git synced 2024-09-20 12:25:20 +00:00
bird/sysdep/unix/io-loop.h

104 lines
1.6 KiB
C
Raw Normal View History

/*
* 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
#ifndef _BIRD_SYSDEP_UNIX_IO_LOOP_H_
#define _BIRD_SYSDEP_UNIX_IO_LOOP_H_
2013-09-10 10:09:36 +00:00
#include "lib/rcu.h"
#include <pthread.h>
struct pipe
{
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 total_time_since {
u64 total;
u64 since;
};
struct birdloop
{
node n;
event event;
timer timer;
pool *pool;
struct timeloop time;
event_list event_list;
list sock_list;
struct birdsock *sock_active;
int sock_num;
uint sock_changed;
2013-09-10 10:09:36 +00:00
uint ping_pending;
_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;
#define TIME_BY_SEC_SIZE 16
u64 time_by_sec_ns[TIME_BY_SEC_SIZE];
u64 last_time_finished_ns;
u64 total_time_spent_ns;
2023-04-26 17:34:29 +00:00
u64 total_time_locking_ns;
};
struct bird_thread
{
node n;
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;
};
2013-09-10 10:09:36 +00:00
#endif