diff options
| author | yo mama <pepper@scannerjammer.com> | 2015-04-04 01:00:59 -0700 |
|---|---|---|
| committer | yo mama <pepper@scannerjammer.com> | 2015-04-04 01:00:59 -0700 |
| commit | c7c22e3db1c826bcfb2bc66651ec480aae0d4ae0 (patch) | |
| tree | 8546df448afef40d3814d2581f4dacff7cebb87f /node_modules/webworker-threads/test/test19_pool_emit_any_all.js | |
Diffstat (limited to 'node_modules/webworker-threads/test/test19_pool_emit_any_all.js')
| -rw-r--r-- | node_modules/webworker-threads/test/test19_pool_emit_any_all.js | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/node_modules/webworker-threads/test/test19_pool_emit_any_all.js b/node_modules/webworker-threads/test/test19_pool_emit_any_all.js new file mode 100644 index 0000000..3133fd1 --- /dev/null +++ b/node_modules/webworker-threads/test/test19_pool_emit_any_all.js @@ -0,0 +1,37 @@ + + +var T= require('webworker-threads'); + +var i= process.argv[2] || 1; +console.log("Creating a pool of "+ i+ " threads"); + +var pool= T.createPool(i); + +pool.all.eval('('+ ƒ+ ')()'); + +pool.on('myEvent', function myEventHandler (data) { + console.log("Received myEvent with data -> "+ data); + if (data === "QUIT") { + setTimeout(function () { pool.destroy() }, 1e3); + } +}); + +function ƒ () { + thread.on('myEvent', function cb (data) { + thread.emit('myEvent', data); + }); +} + + +console.log("pool.any.emit('myEvent', 'POOL.ANY')"); +pool.any.emit('myEvent', "POOL.ANY"); + +console.log("pool.all.emit('myEvent', 'POOL.ALL')"); +pool.all.emit('myEvent', "POOL.ALL"); + +console.log("pool.any.emit('myEvent', 'QUIT')"); +pool.any.emit('myEvent', "QUIT"); + +process.on('exit', function () { + console.log("BYE !"); +}); |
