From 90806a87a4b01496b4867f18c8860a52af55db9d Mon Sep 17 00:00:00 2001 From: Matthew Wild Date: Mon, 9 Jul 2012 02:35:47 +0100 Subject: util.throttle: floor() internal balance calculation --- util/throttle.lua | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/util/throttle.lua b/util/throttle.lua index 2e901158..55e1d07b 100644 --- a/util/throttle.lua +++ b/util/throttle.lua @@ -1,6 +1,7 @@ local gettime = require "socket".gettime; local setmetatable = setmetatable; +local floor = math.floor; module "throttle" @@ -11,7 +12,7 @@ function throttle:update() local newt = gettime(); local elapsed = newt - self.t; self.t = newt; - local balance = self.rate * elapsed + self.balance; + local balance = floor(self.rate * elapsed) + self.balance; if balance > self.max then self.balance = self.max; else -- cgit v1.2.3