File tree Expand file tree Collapse file tree 1 file changed +11
-4
lines changed
Expand file tree Collapse file tree 1 file changed +11
-4
lines changed Original file line number Diff line number Diff line change 44*/
55var child_process = require ( "child_process" ) ;
66
7+ function disconnectWorker ( worker ) {
8+ if ( worker . disconnect )
9+ worker . disconnect ( ) ;
10+ else if ( worker . kill )
11+ worker . kill ( ) ;
12+ else
13+ worker . process . kill ( ) ;
14+ }
15+
716function Workers ( moduleToFork , count ) {
817 this . nextId = 1 ;
918 this . workers = [ ] ;
@@ -49,7 +58,7 @@ Workers.prototype.bindWorker = function(worker, idx) {
4958 callback . apply ( null , result ) ;
5059 } . bind ( this ) ) ;
5160 } else {
52- worker . disconnect ( ) ;
61+ disconnectWorker ( worker ) ;
5362 this . forkedWorkers . splice ( idx , 1 ) ;
5463 }
5564 } . bind ( this ) ) ;
@@ -85,9 +94,7 @@ Workers.prototype.pushJob = function(worker) {
8594}
8695
8796Workers . prototype . close = function ( ) {
88- this . workers . forEach ( function ( worker ) {
89- worker . disconnect ( ) ;
90- } ) ;
97+ this . workers . forEach ( disconnectWorker ) ;
9198 this . workers . length = 0 ;
9299 this . workersJobs . length = 0 ;
93100 this . workersRegister . length = 0 ;
You can’t perform that action at this time.
0 commit comments