Changeset 7579 for trunk/libtransmission/bandwidth.h
- Timestamp:
- Jan 2, 2009, 5:46:22 PM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/libtransmission/bandwidth.h
r7576 r7579 17 17 #ifndef TR_BANDWIDTH_H 18 18 #define TR_BANDWIDTH_H 19 20 #include "transmission.h" 21 #include "ptrarray.h" 22 23 struct tr_peerIo; 24 25 /* these are PRIVATE IMPLEMENTATION details that should not be touched. 26 * it's included in the header for inlining and composition. */ 27 enum 28 { 29 HISTORY_MSEC = 2000, 30 INTERVAL_MSEC = HISTORY_MSEC, 31 GRANULARITY_MSEC = 50, 32 HISTORY_SIZE = ( INTERVAL_MSEC / GRANULARITY_MSEC ), 33 MAGIC_NUMBER = 43143 34 }; 35 36 /* these are PRIVATE IMPLEMENTATION details that should not be touched. 37 * it's included in the header for inlining and composition. */ 38 struct bratecontrol 39 { 40 int newest; 41 struct { uint64_t date, size; } transfers[HISTORY_SIZE]; 42 }; 43 44 /* these are PRIVATE IMPLEMENTATION details that should not be touched. 45 * it's included in the header for inlining and composition. */ 46 struct tr_band 47 { 48 tr_bool isLimited; 49 tr_bool honorParentLimits; 50 size_t bytesLeft; 51 double desiredSpeed; 52 struct bratecontrol raw; 53 struct bratecontrol piece; 54 }; 19 55 20 56 /** … … 57 93 * bandwidth they can safely use. 58 94 */ 59 60 typedef struct tr_bandwidth tr_bandwidth; 61 62 struct tr_peerIo; 95 typedef struct tr_bandwidth 96 { 97 /* these are PRIVATE IMPLEMENTATION details that should not be touched. 98 * it's included in the header for inlining and composition. */ 99 100 struct tr_band band[2]; 101 struct tr_bandwidth * parent; 102 int magicNumber; 103 tr_session * session; 104 tr_ptrArray children; /* struct tr_bandwidth */ 105 tr_ptrArray peers; /* tr_peerIo */ 106 } 107 tr_bandwidth; 108 63 109 64 110 /** … … 75 121 76 122 /** @brief test to see if the pointer refers to a live bandwidth object */ 77 extern inline tr_bool 78 tr_isBandwidth ( const tr_bandwidth * bandwidth ); 123 static inline tr_bool tr_isBandwidth( const tr_bandwidth * b ) 124 { 125 return ( b != NULL ) && ( b->magicNumber == MAGIC_NUMBER ); 126 } 79 127 80 128 /****** … … 87 135 * @see tr_bandwidthGetDesiredSpeed 88 136 */ 89 extern inline void 90 tr_bandwidthSetDesiredSpeed ( tr_bandwidth * bandwidth, 91 tr_direction direction, 92 double desiredSpeed ); 137 static inline void tr_bandwidthSetDesiredSpeed( tr_bandwidth * bandwidth, 138 tr_direction dir, 139 double desiredSpeed ) 140 { 141 bandwidth->band[dir].desiredSpeed = desiredSpeed; 142 } 93 143 94 144 /** … … 96 146 * @see tr_bandwidthSetDesiredSpeed 97 147 */ 98 extern inline double 99 tr_bandwidthGetDesiredSpeed ( const tr_bandwidth * bandwidth, 100 tr_direction direction ); 148 static inline double 149 tr_bandwidthGetDesiredSpeed( const tr_bandwidth * bandwidth, 150 tr_direction dir ) 151 { 152 return bandwidth->band[dir].desiredSpeed; 153 } 101 154 102 155 /** 103 156 * @brief Set whether or not this bandwidth should throttle its peer-io's speeds 104 157 */ 105 extern inline void 106 tr_bandwidthSetLimited ( tr_bandwidth * bandwidth, 107 tr_direction direction, 108 tr_bool isLimited ); 158 static inline void tr_bandwidthSetLimited( tr_bandwidth * bandwidth, 159 tr_direction dir, 160 tr_bool isLimited ) 161 { 162 bandwidth->band[dir].isLimited = isLimited; 163 } 109 164 110 165 /** 111 166 * @return nonzero if this bandwidth throttles its peer-ios speeds 112 167 */ 113 extern inline tr_bool 114 tr_bandwidthIsLimited ( const tr_bandwidth * bandwidth, 115 tr_direction direction ); 168 static inline tr_bool tr_bandwidthIsLimited( const tr_bandwidth * bandwidth, 169 tr_direction dir ) 170 { 171 return bandwidth->band[dir].isLimited; 172 } 116 173 117 174 /** … … 133 190 ******/ 134 191 135 /** 136 * @brief Get the raw total of bytes read or sent by this bandwidth subtree. 137 */ 138 extern inline double 139 tr_bandwidthGetRawSpeed ( const tr_bandwidth * bandwidth, 140 tr_direction direction ); 141 142 /** 143 * @brief Get the number of piece data bytes read or sent by this bandwidth subtree. 144 */ 145 extern inline double 146 tr_bandwidthGetPieceSpeed ( const tr_bandwidth * bandwidth, 147 tr_direction direction ); 192 /** @brief Get the raw total of bytes read or sent by this bandwidth subtree. */ 193 double tr_bandwidthGetRawSpeed( const tr_bandwidth * bandwidth, 194 tr_direction direction ); 195 196 /** @brief Get the number of piece data bytes read or sent by this bandwidth subtree. */ 197 double tr_bandwidthGetPieceSpeed( const tr_bandwidth * bandwidth, 198 tr_direction direction ); 148 199 149 200 /** … … 181 232 * They will be notified when more bandwidth is made available for them to consume. 182 233 */ 183 extern inline void 184 tr_bandwidthAddPeer ( tr_bandwidth * bandwidth, 185 struct tr_peerIo * peerIo ); 234 void tr_bandwidthAddPeer( tr_bandwidth * bandwidth, 235 struct tr_peerIo * peerIo ); 186 236 187 237 /** 188 238 * @brief remove a peer-io from this bandwidth's list. 189 239 */ 190 extern inline void 191 tr_bandwidthRemovePeer ( tr_bandwidth * bandwidth, 192 struct tr_peerIo * peerIo ); 240 void tr_bandwidthRemovePeer( tr_bandwidth * bandwidth, 241 struct tr_peerIo * peerIo ); 193 242 194 243 #endif
Note: See TracChangeset
for help on using the changeset viewer.