mirror of
https://github.com/nodejs/node.git
synced 2026-11-24 21:50:36 -05:00
Signed-off-by: ishabi <ilyasshabi94@gmail.com> PR-URL: https://github.com/nodejs/node/pull/65982 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Stephen Belanger <admin@stephenbelanger.com> Reviewed-By: Bryan English <bryan@bryanenglish.com>
24 lines
850 B
JavaScript
24 lines
850 B
JavaScript
'use strict';
|
|
const common = require('../../common');
|
|
const assert = require('assert');
|
|
const dc = require('diagnostics_channel');
|
|
const test_async = require(`./build/${common.buildType}/test_async`);
|
|
const iterations = 500;
|
|
|
|
let x = 0;
|
|
const events = [];
|
|
const onThreadPoolWork = (event) => events.push(event);
|
|
const workDone = common.mustCall((status) => {
|
|
assert.strictEqual(status, 0);
|
|
if (x === 0) assert.strictEqual(events.length, 0);
|
|
if (++x < iterations) {
|
|
setImmediate(() => test_async.DoRepeatedWork(workDone));
|
|
} else {
|
|
dc.unsubscribe('uv.threadpool.work.node_api', onThreadPoolWork);
|
|
assert.strictEqual(events.length, iterations - 1);
|
|
}
|
|
}, iterations);
|
|
// Subscribe after submission to verify subscription latching.
|
|
test_async.DoRepeatedWork(workDone);
|
|
dc.subscribe('uv.threadpool.work.node_api', onThreadPoolWork);
|