• Home
  • History
  • Annotate
  • Line#
  • Navigate
  • Raw
  • Download
  • only in /netgear-R7000-V1.0.7.12_1.2.5/ap/gpl/transmission/transmission-2.73/libtransmission/
1/*
2 * This file Copyright (C) Mnemosyne LLC
3 *
4 * This file is licensed by the GPL version 2. Works owned by the
5 * Transmission project are granted a special exemption to clause 2(b)
6 * so that the bulk of its code can remain under the MIT license.
7 * This exemption does not extend to derived works not owned by
8 * the Transmission project.
9 *
10 * $Id: history.h 12328 2011-04-06 23:27:11Z jordan $
11 */
12
13#ifndef __TRANSMISSION__
14 #error only libtransmission should #include this header.
15#endif
16
17#ifndef TR_RECENT_HISTORY_H
18#define TR_RECENT_HISTORY_H
19
20/**
21 * A generic short-term memory object that remembers how many times
22 * something happened over the last N seconds.
23 *
24 * For example, it could count how many are bytes transferred
25 * to estimate the speed over the last N seconds.
26 */
27
28enum
29{
30    TR_RECENT_HISTORY_PERIOD_SEC = 60
31};
32
33
34typedef struct tr_recentHistory
35{
36    /* these are PRIVATE IMPLEMENTATION details included for composition only.
37     * Don't access these directly! */
38
39    int newest;
40
41    struct {
42        unsigned int n;
43        time_t date;
44    } slices[TR_RECENT_HISTORY_PERIOD_SEC];
45}
46tr_recentHistory;
47
48/**
49 * @brief add a counter to the recent history object.
50 * @param when the current time in sec, such as from tr_time()
51 * @param n how many items to add to the history's counter
52 */
53void tr_historyAdd( tr_recentHistory *, time_t when, unsigned int n );
54
55/**
56 * @brief count how many events have occurred in the last N seconds.
57 * @param when the current time in sec, such as from tr_time()
58 * @param seconds how many seconds to count back through.
59 */
60unsigned int tr_historyGet( const tr_recentHistory *, time_t when, unsigned int seconds );
61
62#endif
63