Navigation Menu

Skip to content

Commit

Permalink
Correct usage of Coolio::TimerWatcher
Browse files Browse the repository at this point in the history
  • Loading branch information
piroor committed Apr 6, 2015
1 parent b6ce4d9 commit 8c7499a
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion lib/droonga/forwarder.rb
Expand Up @@ -138,15 +138,20 @@ def set_auto_close_timer(host, port, params)
previous_timer = @auto_close_timers[destination]
previous_timer.detach if previous_timer

timer = Coolio::TimerWatcher.new(@auto_close_timeout_seconds) do
timer = Coolio::TimerWatcher.new(@auto_close_timeout_seconds)
on_timeout = lambda do
timer.detach
@auto_close_timers.delete(destination)
sender = @senders[destination]
if sender
logger.info("sender for #{destination} is automatically closed by timeout.")
sender.shutdown
@senders.delete(destination)
end
end
timer.on_timer do
on_timeout.call
end
@loop.attach(timer)
@auto_close_timers[destination] = timer
end
Expand Down

0 comments on commit 8c7499a

Please sign in to comment.