source:
Dev/trunk/src/client/util/build/fileHandleThrottle.js
Last change on this file was 483, checked in by hendrikvanantwerpen, 11 years ago | |
---|---|
File size: 294 bytes |
Rev | Line | |
---|---|---|
[483] | 1 | define([], function(){ |
2 | var | |
3 | count = 0, | |
4 | max = 10, | |
5 | queue = []; | |
6 | return { | |
7 | release:function(){ | |
8 | if(queue.length){ | |
9 | (queue.shift())(); | |
10 | }else{ | |
11 | count--; | |
12 | } | |
13 | }, | |
14 | enqueue:function(proc){ | |
15 | if(count<max){ | |
16 | count++; | |
17 | proc(); | |
18 | }else{ | |
19 | queue.push(proc); | |
20 | } | |
21 | } | |
22 | }; | |
23 | }); |
Note: See TracBrowser
for help on using the repository browser.