diff options
author | Jeremiah Senkpiel <fishrock123@rocketmail.com> | 2017-12-21 05:50:19 +0300 |
---|---|---|
committer | Ruben Bridgewater <ruben@bridgewater.de> | 2017-12-29 02:08:54 +0300 |
commit | f94eec0218419a639c6c0019d8e4a48a894f7aff (patch) | |
tree | c33df308dd0c359449ef447d786c0b8246a4edbe /lib/internal/http.js | |
parent | 8578fe22a973848b4303f915371b98153ed50d44 (diff) |
http: convert utcDate to use setTimeout
A sort-of follow-up to https://github.com/nodejs/node/pull/17704, this
removes the last internal use of enroll().
PR-URL: https://github.com/nodejs/node/pull/17800
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Evan Lucas <evanlucas@me.com>
Reviewed-By: Minwoo Jung <minwoo@nodesource.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Diffstat (limited to 'lib/internal/http.js')
-rw-r--r-- | lib/internal/http.js | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/lib/internal/http.js b/lib/internal/http.js index 71e32498f35..2b9c948aeef 100644 --- a/lib/internal/http.js +++ b/lib/internal/http.js @@ -1,20 +1,21 @@ 'use strict'; -const timers = require('timers'); +const { setUnrefTimeout } = require('internal/timers'); var dateCache; function utcDate() { if (!dateCache) { const d = new Date(); dateCache = d.toUTCString(); - timers.enroll(utcDate, 1000 - d.getMilliseconds()); - timers._unrefActive(utcDate); + + setUnrefTimeout(resetCache, 1000 - d.getMilliseconds()); } return dateCache; } -utcDate._onTimeout = function() { + +function resetCache() { dateCache = undefined; -}; +} function ondrain() { if (this._httpMessage) this._httpMessage.emit('drain'); |