repositories
/
poolifier.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Bump expect from 26.6.0 to 26.6.1
[poolifier.git]
/
lib
/
dynamic.js
diff --git
a/lib/dynamic.js
b/lib/dynamic.js
index cedb8c35b93c0c230f62024bbd9facd04c6e1b7a..36db0c75673ed7a70d4fe5e6e634b2754c38529f 100644
(file)
--- a/
lib/dynamic.js
+++ b/
lib/dynamic.js
@@
-1,6
+1,5
@@
'use strict'
const FixedThreadPool = require('./fixed')
'use strict'
const FixedThreadPool = require('./fixed')
-const { randomWorker } = require('./util')
const EventEmitter = require('events')
class MyEmitter extends EventEmitter {}
const EventEmitter = require('events')
class MyEmitter extends EventEmitter {}
@@
-16,7
+15,6
@@
class DynamicThreadPool extends FixedThreadPool {
*
* @param {Number} min Min number of threads that will be always active
* @param {Number} max Max number of threads that will be active
*
* @param {Number} min Min number of threads that will be always active
* @param {Number} max Max number of threads that will be active
- * @param {Object} an object with possible options for example maxConcurrency
*/
constructor (min, max, filename, opts) {
super(min, filename, opts)
*/
constructor (min, max, filename, opts) {
super(min, filename, opts)
@@
-24,15
+22,6
@@
class DynamicThreadPool extends FixedThreadPool {
this.emitter = new MyEmitter()
}
this.emitter = new MyEmitter()
}
- /**
- * Return an event emitter that will send some messages, for example
- * a message will be sent when max number of threads is reached and all threads are busy
- * in this case it will emit a message
- */
- emitter () {
- return this.emitter
- }
-
_chooseWorker () {
let worker
for (const entry of this.tasks) {
_chooseWorker () {
let worker
for (const entry of this.tasks) {
@@
-48,7
+37,7
@@
class DynamicThreadPool extends FixedThreadPool {
} else {
if (this.workers.length === this.max) {
this.emitter.emit('FullPool')
} else {
if (this.workers.length === this.max) {
this.emitter.emit('FullPool')
- return
randomWorker(this.tasks
)
+ return
super._chooseWorker(
)
}
// all workers are busy create a new worker
const worker = this._newWorker()
}
// all workers are busy create a new worker
const worker = this._newWorker()