Improve performance.

This commit is contained in:
Miao Jiang 2013-02-19 20:54:47 +08:00
parent 02ba0f25d3
commit 1061e177b2
6 changed files with 29 additions and 9 deletions

View file

@ -62,14 +62,24 @@ Curl::perform = ->
Curl.process()
@
m = 0
p = console.log
Curl.process = ->
if Curl.in_process
return
do once = ->
num = Curl.process_()
if num > 0
n = Curl.process_()
if n > 0
Curl.in_process = true
setTimeout once, 80
if n > 8192 && m < 10
++m
process.nextTick once
else
m = 0
w = (8192 - n) * 80 / 8192
if w < 0
w = 0
setTimeout once, w
else
Curl.in_process = false