We have implemented rate-limiting queues where we need them, for
example in the test scripts
tools/test.dart and tools/testing/dart.
One can just use a counter for the outstanding jobs, and when it
reaches a limit, put the next
job in a queue instead of starting it. When a job finishes, the
counter is decremented, and the
queue is checked for a job to start.
One often needs the same kind of counter to ensure that all jobs in a
set of jobs have completed, so
that the next phase of the program can start.
Tricky points are to make sure that the active jobs decrement the
counter whether they finish normally
or call an error handler or throw an exception. The queue can often
consist of closures, just containing the
function call to do the job.
--
William Hesse
Software Engineer
whe...@google.com
Google Denmark ApS
Frederiksborggade 20B, 1 sal
1360 København K
Denmark
CVR nr. 28 86 69 84
If you received this communication by mistake, please don't forward it
to anyone else (it may contain confidential or privileged
information), please erase all copies of it, including all
attachments, and please let the sender know it went to the wrong
person. Thanks.