mirror of
https://github.com/nodejs/node.git
synced 2024-12-01 16:10:02 +01:00
aa363c49ea
This commit replaces common.busyLoop() with sleep(). PR-URL: https://github.com/nodejs/node/pull/30787 Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Gus Caplan <me@gus.host> Reviewed-By: Richard Lau <riclau@uk.ibm.com>
21 lines
400 B
JavaScript
21 lines
400 B
JavaScript
// Flags: --expose-internals
|
|
'use strict';
|
|
|
|
const common = require('../common');
|
|
const assert = require('assert');
|
|
const { sleep } = require('internal/util');
|
|
|
|
let called = false;
|
|
const t1 = setInterval(() => {
|
|
assert(!called);
|
|
called = true;
|
|
setImmediate(common.mustCall(() => {
|
|
clearInterval(t1);
|
|
clearInterval(t2);
|
|
}));
|
|
}, 10);
|
|
|
|
const t2 = setInterval(() => {
|
|
sleep(20);
|
|
}, 10);
|