mirror of
https://github.com/transmission/transmission.git
synced 2025-12-24 20:35:36 +00:00
There're places where manual intervention is still required as uncrustify is not ideal (unfortunately), but at least one may rely on it to do the right thing most of the time (e.g. when sending in a patch). The style itself is quite different from what we had before but making it uniform across all the codebase is the key. I also hope that it'll make the code more readable (YMMV) and less sensitive to further changes.
56 lines
1.4 KiB
C
56 lines
1.4 KiB
C
/*
|
|
* This file Copyright (C) 2010-2014 Mnemosyne LLC
|
|
*
|
|
* It may be used under the GNU GPL versions 2 or 3
|
|
* or any future license endorsed by Mnemosyne LLC.
|
|
*
|
|
*/
|
|
|
|
#ifndef __TRANSMISSION__
|
|
#error only libtransmission should #include this header.
|
|
#endif
|
|
|
|
#pragma once
|
|
|
|
/**
|
|
* A generic short-term memory object that remembers how many times
|
|
* something happened over the last N seconds.
|
|
*
|
|
* For example, it could count how many are bytes transferred
|
|
* to estimate the speed over the last N seconds.
|
|
*/
|
|
|
|
enum
|
|
{
|
|
TR_RECENT_HISTORY_PERIOD_SEC = 60
|
|
};
|
|
|
|
typedef struct tr_recentHistory
|
|
{
|
|
/* these are PRIVATE IMPLEMENTATION details included for composition only.
|
|
* Don't access these directly! */
|
|
|
|
int newest;
|
|
|
|
struct
|
|
{
|
|
unsigned int n;
|
|
time_t date;
|
|
} slices[TR_RECENT_HISTORY_PERIOD_SEC];
|
|
}
|
|
tr_recentHistory;
|
|
|
|
/**
|
|
* @brief add a counter to the recent history object.
|
|
* @param when the current time in sec, such as from tr_time ()
|
|
* @param n how many items to add to the history's counter
|
|
*/
|
|
void tr_historyAdd(tr_recentHistory*, time_t when, unsigned int n);
|
|
|
|
/**
|
|
* @brief count how many events have occurred in the last N seconds.
|
|
* @param when the current time in sec, such as from tr_time ()
|
|
* @param seconds how many seconds to count back through.
|
|
*/
|
|
unsigned int tr_historyGet(const tr_recentHistory*, time_t when, unsigned int seconds);
|