5 ms·
// check if we're toobusy() - note, this call is extremely fast, and returns // state that is calculated asynchronously. if (toobusy()) res.send(503, "I'm
by mnarayan01 14y ago
// check if we're toobusy() - note, this call is extremely fast, and returns
// state that is calculated asynchronously.
if (toobusy()) res.send(503, "I'm busy right now, sorry.");
Saying it is calculated "asynchronously" seems pretty confusing in this context. Maybe "is cached at a fixed interval"?
- lloydhilaiel 14y agoI agree. /me fixes
- firefoxman1 14y agoSide note: caching at a fixed interval is a great way to save CPU cycles. If you're serving 100req/s and you had to grab the current time within 1sec accuracy for them, you could have 1/100th the amount of Date calls by getting the time each second instead of each request.
- wereHamster 14y agoNope, it is literally calculated asynchronously. Look at https://github.com/lloyd/node-toobusy/blob/master/toobusy.cc#L63 https://github.com/lloyd/node-toobusy/blob/master/toobusy.cc... and lines 91/92 which sets up the background timer.