以节流方式执行 async 回调任务
A helper to prevent accumulation of sequential async tasks.
Imagine a mail man with the sole task of delivering letters. As soon as
a letter submitted for delivery, he drives to the destination, delivers it
and returns to his base. Imagine that during the trip, N more letters were submitted.
When the mail man returns, he picks those N letters and delivers them all in a
single trip. Even though N+1 submissions occurred, only 2 deliveries were made.
The throttler implements this via the queue() method, by providing it a task
factory. Following the example:
Imagine a mail man with the sole task of delivering letters. As soon as a letter submitted for delivery, he drives to the destination, delivers it and returns to his base. Imagine that during the trip, N more letters were submitted. When the mail man returns, he picks those N letters and delivers them all in a single trip. Even though N+1 submissions occurred, only 2 deliveries were made.
The throttler implements this via the queue() method, by providing it a task factory. Following the example: