Ignore:
Timestamp:
Jan 2, 2009, 5:46:22 PM (12 years ago)
Author:
charles
Message:

(trunk libT) inline parts of peer-io and bandwidth, too

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/libtransmission/bandwidth.c

    r7576 r7579  
    2727***/
    2828
    29 enum
    30 {
    31     HISTORY_MSEC = 2000,
    32     INTERVAL_MSEC = HISTORY_MSEC,
    33     GRANULARITY_MSEC = 50,
    34     HISTORY_SIZE = ( INTERVAL_MSEC / GRANULARITY_MSEC ),
    35     MAGIC_NUMBER = 43143
    36 };
    37 
    38 struct bratecontrol
    39 {
    40     int newest;
    41     struct { uint64_t date, size; } transfers[HISTORY_SIZE];
    42 };
    43 
    4429static float
    4530getSpeed( const struct bratecontrol * r, int interval_msec )
     
    8368******/
    8469
    85 struct tr_band
    86 {
    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_bandwidth
    96 {
    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 
    10970static inline int
    11071comparePointers( const void * a, const void * b )
     
    11475
    11576    return 0;
    116 }
    117 
    118 tr_bool
    119 tr_isBandwidth( const tr_bandwidth * b )
    120 {
    121     return ( b != NULL ) && ( b->magicNumber == MAGIC_NUMBER );
    12277}
    12378
     
    196151***/
    197152
    198 void
    199 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 double
    210 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 void
    220 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_bool
    231 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 
    240153#if 0
    241154#warning do not check the code in with this enabled
     
    359272    assert( tr_isPeerIo( peerIo ) );
    360273
    361     tr_ptrArrayInsertSorted( &b->peers, peerIo, comparePointers );
    362274}
    363275
Note: See TracChangeset for help on using the changeset viewer.