Annotation of embedaddon/bird/proto/bfd/io.h, revision 1.1

1.1     ! misho       1: /*
        !             2:  *     BIRD -- I/O and event loop
        !             3:  *
        !             4:  *     Can be freely distributed and used under the terms of the GNU GPL.
        !             5:  */
        !             6: 
        !             7: #ifndef _BIRD_BFD_IO_H_
        !             8: #define _BIRD_BFD_IO_H_
        !             9: 
        !            10: #include "nest/bird.h"
        !            11: #include "lib/lists.h"
        !            12: #include "lib/resource.h"
        !            13: #include "lib/event.h"
        !            14: #include "lib/socket.h"
        !            15: // #include "lib/timer.h"
        !            16: 
        !            17: 
        !            18: typedef struct timer2
        !            19: {
        !            20:   resource r;
        !            21:   void (*hook)(struct timer2 *);
        !            22:   void *data;
        !            23: 
        !            24:   btime expires;                       /* 0=inactive */
        !            25:   uint randomize;                      /* Amount of randomization */
        !            26:   uint recurrent;                      /* Timer recurrence */
        !            27: 
        !            28:   int index;
        !            29: } timer2;
        !            30: 
        !            31: 
        !            32: btime current_time(void);
        !            33: 
        !            34: void ev2_schedule(event *e);
        !            35: 
        !            36: 
        !            37: timer2 *tm2_new(pool *p);
        !            38: void tm2_set(timer2 *t, btime when);
        !            39: void tm2_start(timer2 *t, btime after);
        !            40: void tm2_stop(timer2 *t);
        !            41: 
        !            42: static inline int
        !            43: tm2_active(timer2 *t)
        !            44: {
        !            45:   return t->expires != 0;
        !            46: }
        !            47: 
        !            48: static inline btime 
        !            49: tm2_remains(timer2 *t)
        !            50: {
        !            51:   btime now = current_time();
        !            52:   return (t->expires > now) ? (t->expires - now) : 0;
        !            53: }
        !            54: 
        !            55: static inline timer2 *
        !            56: tm2_new_init(pool *p, void (*hook)(struct timer2 *), void *data, uint rec, uint rand)
        !            57: {
        !            58:   timer2 *t = tm2_new(p);
        !            59:   t->hook = hook;
        !            60:   t->data = data;
        !            61:   t->recurrent = rec;
        !            62:   t->randomize = rand;
        !            63:   return t;
        !            64: }
        !            65: 
        !            66: static inline void
        !            67: tm2_set_max(timer2 *t, btime when)
        !            68: {
        !            69:   if (when > t->expires)
        !            70:     tm2_set(t, when);
        !            71: }
        !            72: 
        !            73: /*
        !            74: static inline void
        !            75: tm2_start_max(timer2 *t, btime after)
        !            76: {
        !            77:   btime rem = tm2_remains(t);
        !            78:   tm2_start(t, MAX_(rem, after));
        !            79: }
        !            80: */
        !            81: 
        !            82: 
        !            83: void sk_start(sock *s);
        !            84: void sk_stop(sock *s);
        !            85: 
        !            86: 
        !            87: 
        !            88: struct birdloop *birdloop_new(void);
        !            89: void birdloop_start(struct birdloop *loop);
        !            90: void birdloop_stop(struct birdloop *loop);
        !            91: void birdloop_free(struct birdloop *loop);
        !            92: 
        !            93: void birdloop_enter(struct birdloop *loop);
        !            94: void birdloop_leave(struct birdloop *loop);
        !            95: void birdloop_mask_wakeups(struct birdloop *loop);
        !            96: void birdloop_unmask_wakeups(struct birdloop *loop);
        !            97: 
        !            98: 
        !            99: #endif /* _BIRD_BFD_IO_H_ */

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>