source: trunk/libtransmission/history.h @ 11599

Last change on this file since 11599 was 11599, checked in by charles, 11 years ago

(trunk) Join the 21st century and use only 1 space at the end sentences. This commit is nearly as important as the semi-annual ones that remove trailing spaces from the ends of lines of code... :)

  • Property svn:keywords set to Date Rev Author Id
File size: 1.8 KB
Line 
1/*
2 * This file Copyright (C) 2010 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 11599 2010-12-27 19:18:17Z charles $
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 */
27typedef struct tr_recentHistory tr_recentHistory;
28
29/**
30 * @brief create a new tr_recentHistory object.
31 * @param seconds how many seconds of history this object should remember
32 * @param precision how precise the history should be, in seconds
33 *        For a precision of 10 seconds and a history of 2 minutes, makes 12 bins.
34 */
35tr_recentHistory * tr_historyNew( unsigned int seconds, unsigned int precision );
36
37/** @brief destroy an existing tr_recentHistory object. */
38void tr_historyFree( tr_recentHistory * );
39
40/**
41 * @brief add a counter to the recent history object.
42 * @param when the current time in sec, such as from tr_time()
43 * @param n how many items to add to the history's counter
44 */
45void tr_historyAdd( tr_recentHistory *, time_t when, unsigned int n );
46
47/**
48 * @brief count how many events have occurred in the last N seconds.
49 * @param when the current time in sec, such as from tr_time()
50 * @param seconds how many seconds to count back through.
51 */
52unsigned int tr_historyGet( const tr_recentHistory *, time_t when, unsigned int seconds );
53
54#endif
Note: See TracBrowser for help on using the repository browser.