diff options
author | Anatoli Papirovski <apapirovski@mac.com> | 2018-05-23 02:01:53 +0400 |
---|---|---|
committer | Anatoli Papirovski <apapirovski@mac.com> | 2018-06-01 10:29:51 +0200 |
commit | 48a2568f411cf09999b7e82992d15142ce9a45b0 (patch) | |
tree | 3758361e4577bd5a253f17a25ef726f30a9b96e0 /test/parallel/test-timers-unref.js | |
parent | de732725d8ae232d7b6d56927ea8bef471d5bf1d (diff) | |
download | android-node-v8-48a2568f411cf09999b7e82992d15142ce9a45b0.tar.gz android-node-v8-48a2568f411cf09999b7e82992d15142ce9a45b0.tar.bz2 android-node-v8-48a2568f411cf09999b7e82992d15142ce9a45b0.zip |
timers: add hasRef method to Timeout & Immediate
Provide a way to check whether the current timer or immediate is refed.
PR-URL: https://github.com/nodejs/node/pull/20898
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
Diffstat (limited to 'test/parallel/test-timers-unref.js')
-rw-r--r-- | test/parallel/test-timers-unref.js | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/test/parallel/test-timers-unref.js b/test/parallel/test-timers-unref.js index 8c4891f1ed..35615d111a 100644 --- a/test/parallel/test-timers-unref.js +++ b/test/parallel/test-timers-unref.js @@ -23,6 +23,8 @@ const common = require('../common'); +const assert = require('assert'); + let unref_interval = false; let unref_timer = false; let checks = 0; @@ -30,8 +32,12 @@ let checks = 0; const LONG_TIME = 10 * 1000; const SHORT_TIME = 100; +const timer = setTimeout(() => {}, 10); +assert.strictEqual(timer.hasRef(), true); // Should not throw. -setTimeout(() => {}, 10).unref().ref().unref(); +timer.unref().ref().unref(); +assert.strictEqual(timer.hasRef(), false); + setInterval(() => {}, 10).unref().ref().unref(); setInterval(common.mustNotCall('Interval should not fire'), LONG_TIME).unref(); |