source: trunk/libtransmission/history.h

Last change on this file was 14724, checked in by jordan, 5 years ago

use '#pragma once' instead of #ifndef..#define..#endif guards

  • Property svn:keywords set to Date Rev Author Id
File size: 1.4 KB
Line 
1/*
2 * This file Copyright (C) 2010-2014 Mnemosyne LLC
3 *
4 * It may be used under the GNU GPL versions 2 or 3
5 * or any future license endorsed by Mnemosyne LLC.
6 *
7 * $Id: history.h 14724 2016-03-29 16:37:21Z mikedld $
8 */
9
10#ifndef __TRANSMISSION__
11 #error only libtransmission should #include this header.
12#endif
13
14#pragma once
15
16/**
17 * A generic short-term memory object that remembers how many times
18 * something happened over the last N seconds.
19 *
20 * For example, it could count how many are bytes transferred
21 * to estimate the speed over the last N seconds.
22 */
23
24enum
25{
26  TR_RECENT_HISTORY_PERIOD_SEC = 60
27};
28
29
30typedef struct tr_recentHistory
31{
32  /* these are PRIVATE IMPLEMENTATION details included for composition only.
33   * Don't access these directly! */
34
35  int newest;
36
37  struct {
38    unsigned int n;
39    time_t date;
40  } slices[TR_RECENT_HISTORY_PERIOD_SEC];
41}
42tr_recentHistory;
43
44/**
45 * @brief add a counter to the recent history object.
46 * @param when the current time in sec, such as from tr_time ()
47 * @param n how many items to add to the history's counter
48 */
49void tr_historyAdd (tr_recentHistory *, time_t when, unsigned int n);
50
51/**
52 * @brief count how many events have occurred in the last N seconds.
53 * @param when the current time in sec, such as from tr_time ()
54 * @param seconds how many seconds to count back through.
55 */
56unsigned int tr_historyGet (const tr_recentHistory *, time_t when, unsigned int seconds);
57
Note: See TracBrowser for help on using the repository browser.