node/test/simple/test-eio-limit.js

29 lines
486 B
JavaScript
Raw Normal View History

2012-01-15 01:48:56 +08:00
var assert = require('assert'),
zlib = require('zlib'),
started = 0,
done = 0;
function repeat(fn) {
if (started != 0) {
assert.ok(started - done < 100)
}
process.nextTick(function() {
fn();
repeat(fn);
});
}
repeat(function() {
if (started > 1000) return process.exit(0);
for (var i = 0; i < 30; i++) {
started++;
var deflate = zlib.createDeflate();
deflate.write('123');
deflate.flush(function() {
done++;
});
}
});