Changeset

4953:24c2150cc8b0

Merge 0.9->trunk
author Matthew Wild <mwild1@gmail.com>
date Mon, 09 Jul 2012 02:36:09 +0100
parents 4951:e3ff2656cb37 (current diff) 4952:0e9a5b63206a (diff)
children 4956:bc26e6d519ae 4978:0b9e86302de4
files
diffstat 1 files changed, 2 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/util/throttle.lua	Sun Jul 08 18:54:56 2012 +0100
+++ b/util/throttle.lua	Mon Jul 09 02:36:09 2012 +0100
@@ -1,6 +1,7 @@
 
 local gettime = require "socket".gettime;
 local setmetatable = setmetatable;
+local floor = math.floor;
 
 module "throttle"
 
@@ -11,7 +12,7 @@
 	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