1 /* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
2 /* expirelist.h List of stuff that expires
4 * Copyright (C) 2003 Red Hat, Inc.
6 * Licensed under the Academic Free License version 2.1
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
24 #ifndef BUS_EXPIRE_LIST_H
25 #define BUS_EXPIRE_LIST_H
27 #include <dbus/dbus.h>
28 #include <dbus/dbus-list.h>
29 #include <dbus/dbus-mainloop.h>
31 typedef struct BusExpireList BusExpireList;
32 typedef struct BusExpireItem BusExpireItem;
34 typedef dbus_bool_t (* BusExpireFunc) (BusExpireList *list,
39 /* embed this in a child expire item struct */
42 long added_tv_sec; /**< Time we were added (seconds component) */
43 long added_tv_usec; /**< Time we were added (microsec component) */
46 BusExpireList* bus_expire_list_new (DBusLoop *loop,
48 BusExpireFunc expire_func,
50 void bus_expire_list_free (BusExpireList *list);
51 void bus_expire_list_recheck_immediately (BusExpireList *list);
52 void bus_expire_list_remove_link (BusExpireList *list,
54 dbus_bool_t bus_expire_list_remove (BusExpireList *list,
56 DBusList* bus_expire_list_get_first_link (BusExpireList *list);
57 DBusList* bus_expire_list_get_next_link (BusExpireList *list,
59 dbus_bool_t bus_expire_list_add (BusExpireList *list,
61 void bus_expire_list_add_link (BusExpireList *list,
63 dbus_bool_t bus_expire_list_contains_item (BusExpireList *list,
65 void bus_expire_list_unlink (BusExpireList *list,
68 /* this macro and function are semi-related utility functions, not really part of the
72 #define ELAPSED_MILLISECONDS_SINCE(orig_tv_sec, orig_tv_usec, \
73 now_tv_sec, now_tv_usec) \
74 (((double) (now_tv_sec) - (double) (orig_tv_sec)) * 1000.0 + \
75 ((double) (now_tv_usec) - (double) (orig_tv_usec)) / 1000.0)
77 void bus_expire_timeout_set_interval (DBusTimeout *timeout,
80 #endif /* BUS_EXPIRE_LIST_H */