summaryrefslogtreecommitdiff
path: root/node_modules/webworker-threads/test/test25_delete_puts.js
blob: 1e30fff17d09a3769a624cad489b7a7d38e11423 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
/*

If you don't want a thread to have the privilege of writing to stdout, simply delete its global puts symbol

*/

var Threads= require('webworker-threads');

function cb (err, msg) {
  if (err) {
    process.stdout.write("["+ this.id+ "] -> "+ err+ '\n');
  }
  this.destroy();
}

function ƒ () {
  puts("["+ thread.id+ "] -> puts('Hello!')\n");
}

var i= Math.abs(parseInt(process.argv[2], 10)) || 1;
console.log('Using '+ i+ ' threads');

Threads.createPool(i).all.eval('delete (global= this).puts; ('+ ƒ+ ')();', cb);