lib/lifx/timers.rb in lifx-0.4.7 vs lib/lifx/timers.rb in lifx-0.4.8
- old
+ new
@@ -3,16 +3,24 @@
# @private
module Timers
protected
def initialize_timer_thread
timers.after(1) {} # Just so timers.wait doesn't complain when there's no timer
- Thread.new do
+ @timer_thread = Thread.start do
loop do
timers.wait
end
end
end
+ def stop_timers
+ timers.each(&:cancel)
+ if @timer_thread
+ @timer_thread.abort
+ end
+ end
+
+ public
def timers
@timers ||= ::Timers.new
end
end
end