Skip to content

Commit

Permalink
examples/cqueues-slave: Take ceiling of timeout for libuv
Browse files Browse the repository at this point in the history
It will error if you give it a non-integer
  • Loading branch information
daurnimator committed Nov 29, 2015
1 parent 76d9293 commit 5965279
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion examples/cqueues-slave.lua
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@ do
local function reset_timer()
local timeout = cq:timeout()
if timeout then
timer:set_repeat(timeout * 1000)
-- libuv takes milliseconds as an integer,
-- while cqueues gives timeouts as a floating point number
-- use `math.ceil` as we'd rather wake up late than early
timer:set_repeat(math.ceil(timeout * 1000))
timer:again()
end
end
Expand Down

0 comments on commit 5965279

Please sign in to comment.