2 This file is part of GNUnet.
3 Copyright (C) 2010 GNUnet e.V.
5 GNUnet is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published
7 by the Free Software Foundation; either version 3, or (at your
8 option) any later version.
10 GNUnet is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with GNUnet; see the file COPYING. If not, write to the
17 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 Boston, MA 02110-1301, USA.
22 * @author Christian Grothoff
25 * Functions related to load calculations
27 * @defgroup load Load library
32 #ifndef GNUNET_LOAD_LIB_H
33 #define GNUNET_LOAD_LIB_H
38 #if 0 /* keep Emacsens' auto-indent happy */
43 #include "gnunet_common.h"
44 #include "gnunet_time_lib.h"
49 struct GNUNET_LOAD_Value;
52 * Create a new load value.
54 * @param autodecline speed at which this value should automatically
55 * decline in the absence of external events; at the given
56 * frequency, 0-load values will be added to the load
57 * @return the new load value
59 struct GNUNET_LOAD_Value *
60 GNUNET_LOAD_value_init (struct GNUNET_TIME_Relative autodecline);
64 * Change the value by which the load automatically declines.
66 * @param load load to update
67 * @param autodecline frequency of load decline
70 GNUNET_LOAD_value_set_decline (struct GNUNET_LOAD_Value *load,
71 struct GNUNET_TIME_Relative autodecline);
77 * @param lv value to free
79 #define GNUNET_LOAD_value_free(lv) GNUNET_free (lv)
83 * Get the current load.
85 * @param load load handle
86 * @return zero for below-average load, otherwise
87 * number of std. devs we are above average;
88 * 100 if the latest updates were so large
89 * that we could not do proper calculations
92 GNUNET_LOAD_get_load (struct GNUNET_LOAD_Value *load);
96 * Get the average value given to update so far.
98 * @param load load handle
99 * @return zero if update was never called
102 GNUNET_LOAD_get_average (struct GNUNET_LOAD_Value *load);
106 * Update the current load.
108 * @param load to update
109 * @param data latest measurement value (for example, delay)
112 GNUNET_LOAD_update (struct GNUNET_LOAD_Value *load, uint64_t data);
115 #if 0 /* keep Emacsens' auto-indent happy */
122 /* ifndef GNUNET_LOAD_LIB_H */
125 /** @} */ /* end of group */
127 /* end of gnunet_load_lib.h */