task-simple-limiter
v3.3.0
Published
使用阻塞函数来控制并发 Use await calls of method which can block async process to control the concurrency
Downloads
13
Maintainers
Readme
Task Simple Limiter
本包可以方便的给异步任务限流,也就是并发控制。
Task Simple Limiter can control your tasks concurrency conveniently.
用例 Usage
初始化 Initialization
import Limiter from 'task-simple-limiter';
const limiter = new Limiter({ concurrency: 2 });
阻塞任务来限流 Blocking Task
async function task() {
const release = await limiter.hold();
try {
await somethingAsync();
}
finally {
release();
}
}
链接 Links
限制并发的实现方式与本包类似。
The way to control concurrency is similar to this package.