1 /* -*- mode: C; c-file-style: "gnu" -*- */
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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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,
40 DBusList *items; /**< List of BusExpireItem */
43 BusExpireFunc expire_func;
45 int expire_after; /**< Expire after milliseconds (thousandths) */
48 /* embed this in a child expire item struct */
51 long added_tv_sec; /**< Time we were added (seconds component) */
52 long added_tv_usec; /**< Time we were added (microsec component) */
55 BusExpireList* bus_expire_list_new (DBusLoop *loop,
57 BusExpireFunc expire_func,
59 void bus_expire_list_free (BusExpireList *list);
61 #define ELAPSED_MILLISECONDS_SINCE(orig_tv_sec, orig_tv_usec, \
62 now_tv_sec, now_tv_usec) \
63 (((double) (now_tv_sec) - (double) (orig_tv_sec)) * 1000.0 + \
64 ((double) (now_tv_usec) - (double) (orig_tv_usec)) / 1000.0)
66 void bus_expire_timeout_set_interval (DBusTimeout *timeout,
69 #endif /* BUS_EXPIRE_LIST_H */