Changeset 7579 for trunk/libtransmission/bandwidth.c
- Timestamp:
- Jan 2, 2009, 5:46:22 PM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/libtransmission/bandwidth.c
r7576 r7579 27 27 ***/ 28 28 29 enum30 {31 HISTORY_MSEC = 2000,32 INTERVAL_MSEC = HISTORY_MSEC,33 GRANULARITY_MSEC = 50,34 HISTORY_SIZE = ( INTERVAL_MSEC / GRANULARITY_MSEC ),35 MAGIC_NUMBER = 4314336 };37 38 struct bratecontrol39 {40 int newest;41 struct { uint64_t date, size; } transfers[HISTORY_SIZE];42 };43 44 29 static float 45 30 getSpeed( const struct bratecontrol * r, int interval_msec ) … … 83 68 ******/ 84 69 85 struct tr_band86 {87 tr_bool isLimited;88 tr_bool honorParentLimits;89 size_t bytesLeft;90 double desiredSpeed;91 struct bratecontrol raw;92 struct bratecontrol piece;93 };94 95 struct tr_bandwidth96 {97 struct tr_band band[2];98 struct tr_bandwidth * parent;99 int magicNumber;100 tr_session * session;101 tr_ptrArray children; /* struct tr_bandwidth */102 tr_ptrArray peers; /* tr_peerIo */103 };104 105 /***106 ****107 ***/108 109 70 static inline int 110 71 comparePointers( const void * a, const void * b ) … … 114 75 115 76 return 0; 116 }117 118 tr_bool119 tr_isBandwidth( const tr_bandwidth * b )120 {121 return ( b != NULL ) && ( b->magicNumber == MAGIC_NUMBER );122 77 } 123 78 … … 196 151 ***/ 197 152 198 void199 tr_bandwidthSetDesiredSpeed( tr_bandwidth * b,200 tr_direction dir,201 double desiredSpeed )202 {203 assert( tr_isBandwidth( b ) );204 assert( tr_isDirection( dir ) );205 206 b->band[dir].desiredSpeed = desiredSpeed;207 }208 209 double210 tr_bandwidthGetDesiredSpeed( const tr_bandwidth * b,211 tr_direction dir )212 {213 assert( tr_isBandwidth( b ) );214 assert( tr_isDirection( dir ) );215 216 return b->band[dir].desiredSpeed;217 }218 219 void220 tr_bandwidthSetLimited( tr_bandwidth * b,221 tr_direction dir,222 tr_bool isLimited )223 {224 assert( tr_isBandwidth( b ) );225 assert( tr_isDirection( dir ) );226 227 b->band[dir].isLimited = isLimited;228 }229 230 tr_bool231 tr_bandwidthIsLimited( const tr_bandwidth * b,232 tr_direction dir )233 {234 assert( tr_isBandwidth( b ) );235 assert( tr_isDirection( dir ) );236 237 return b->band[dir].isLimited;238 }239 240 153 #if 0 241 154 #warning do not check the code in with this enabled … … 359 272 assert( tr_isPeerIo( peerIo ) ); 360 273 361 tr_ptrArrayInsertSorted( &b->peers, peerIo, comparePointers );362 274 } 363 275
Note: See TracChangeset
for help on using the changeset viewer.