pc-queue
v1.0.0
Published
A queue for producer-consumer model
Downloads
2
Maintainers
Readme
A queue for producer-consumer model
✨ Example
create one Queue with one consumer and two producer
const Queue = require('./index')
// 1. define queue instance
const queue = new Queue(2) //concurrency=2
// 2. consumer do something
var doSth=function(data,i){
console.log(`consume${i}: `,data)
}
// 3. begin consume
queue.run(doSth)
setInterval(function(){
// 4. begin produce
queue.push(Math.random())
},1000)
output
consume0: 0.8152931321636179
consume1: 0.10340654794346626
consume0: 0.7497420856391879
consume1: 0.7854904441673309
consume0: 0.9786641059681527
Install
npm install
Run tests
npm run test
Author
👤 selenium39
- Website: https://blog.csdn.net/qq_45453266
- Github: @wantao666
🤝 Contributing
Contributions, issues and feature requests are welcome!Feel free to check issues page. You can also take a look at the contributing guide.
Show your support
Give a ⭐️ if this project helped you!
📝 License
Copyright © 2021 selenium39. This project is MIT licensed.
This README was generated with ❤️ by readme-md-generator