]> git.proxmox.com Git - mirror_frr.git/blame - lib/wheel.h
zebra: Fix compile warnings under freebsd
[mirror_frr.git] / lib / wheel.h
CommitLineData
cbea8737
DS
1/*
2 * Timer Wheel
3 * Copyright (C) 2016 Cumulus Networks, Inc.
4 * Donald Sharp
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; see the file COPYING; if not, write to the
18 * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
19 * MA 02110-1301 USA
20 */
21#ifndef __WHEEL_H__
22#define __WHEEL_H__
23
24struct timer_wheel
25{
26 struct thread_master *master;
27 int slots;
28 long long curr_slot;
29 unsigned int period;
30 unsigned int nexttime;
31 unsigned int slots_to_skip;
32
33 struct list **wheel_slot_lists;
34 struct thread *timer;
35 /*
36 * Key to determine what slot the item belongs in
37 */
38 unsigned int (*slot_key) (void *);
39
40 void (*slot_run) (void *);
41};
42
43struct timer_wheel *wheel_init (struct thread_master *master, int period, size_t slots,
44 unsigned int (*slot_key) (void *),
45 void (*slot_run) (void *));
46void wheel_delete (struct timer_wheel *);
47
48/*
49 * Pause the Wheel from running
50 */
51int wheel_stop (struct timer_wheel *wheel);
52
53/*
54 * Start the wheel from running again
55 */
56int wheel_start (struct timer_wheel *wheel);
57
58/*
59 * Add item to a slot setup by the slot_key,
60 * possibly change next time pop.
61 */
62int wheel_add_item (struct timer_wheel *wheel, void *item);
63
64/*
65 * Remove a item to a slot setup by the slot_key,
66 * possibly change next time pop.
67 */
68int wheel_remove_item (struct timer_wheel *wheel, void *item);
69
70#endif