Toggle navigation
Toggle navigation
This project
Loading...
Sign in
iOS
/
asi-http-request
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Authored by
Ben Copsey
2009-11-25 17:32:11 +0000
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
965984c19c363c47bbd254a4f13b6dac6d5fb7bd
965984c1
1 parent
d156fef3
Hopefully improved accuracy of Bandwidth throttling
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
4 deletions
Classes/ASIHTTPRequest.m
Classes/ASIHTTPRequest.m
View file @
965984c
...
...
@@ -2986,6 +2986,7 @@ static BOOL isiPhoneOS2;
interval
++
;
}
}
//NSLog(@"Used: %qi",bandwidthUsedInLastSecond);
[
bandwidthUsageTracker
addObject
:[
NSNumber
numberWithUnsignedLong
:
bandwidthUsedInLastSecond
]];
[
bandwidthMeasurementDate
release
];
...
...
@@ -3025,12 +3026,15 @@ static BOOL isiPhoneOS2;
if
(
maxBandwidthPerSecond
>
0
)
{
// How much data can we still send or receive this second?
long
long
bytesRemaining
=
(
long
long
)
maxBandwidthPerSecond
-
(
long
long
)
bandwidthUsedInLastSecond
;
// Have we used up our allowance?
if
(
bytesRemaining
<
8
)
{
if
(
bytesRemaining
<
0
)
{
// Yes, put this request to sleep until a second is up, with extra added punishment sleeping time for being very naughty (we have used more bandwidth than we were allowed)
double
extraSleepyTime
=
(
-
bytesRemaining
/
(
maxBandwidthPerSecond
*
1
.
0
));
// Yes, put this request to sleep until a second is up
[
NSThread
sleepUntilDate
:
bandwidthMeasurementDate
];
[
NSThread
sleepUntilDate
:[
bandwidthMeasurementDate
dateByAddingTimeInterval
:
extraSleepyTime
]];
[
self
recordBandwidthUsage
];
}
}
...
...
Please
register
or
login
to post a comment