Skip to content

Commit

Permalink
++puts() tests
Browse files Browse the repository at this point in the history
  • Loading branch information
xk committed Mar 23, 2012
1 parent b525538 commit 92c8526
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 3 deletions.
2 changes: 1 addition & 1 deletion test/test27_puts_event_loop.js
Expand Up @@ -8,7 +8,7 @@ pool.on('again', function onAgain () {

function ƒ () {
puts(" ["+ thread.id+ "]"+ (++i));
thread.emit('again', 0);
thread.emit('again');
}

pool.all.eval(ƒ).all.eval('i=0').all.eval('ƒ()');
5 changes: 3 additions & 2 deletions test/test28_puts_nextTick_loop.js
Expand Up @@ -4,10 +4,11 @@ console.log("Using "+ i+ " threads.");

function program () {
var i= 0;
(function ƒ () {
function ƒ () {
puts(" ["+ thread.id+ "]"+ (++i));
thread.nextTick(ƒ);
})();
}
ƒ();
}

pool.all.eval(program).all.eval('program()');
14 changes: 14 additions & 0 deletions test/test29_puts_callback_loop.js
@@ -0,0 +1,14 @@
var i= parseInt(process.argv[2], 10) || 2;
var pool= require('threads_a_gogo').createPool(i);
console.log("Using "+ i+ " threads.");

function ƒ () {
puts(" ["+ thread.id+ "]"+ (++i));
//if (!(i%1e3)) gc();
}

function callback (err, data) {
this.eval('ƒ()', callback);
}

pool.all.eval('i=0').all.eval(ƒ).all.eval('ƒ()', callback);

0 comments on commit 92c8526

Please sign in to comment.