epoll/client: thread-safety for write queuing
[rainbows.git] / lib / rainbows / fiber / coolio / heartbeat.rb
blob6b1e4f9620dc3c3069fdc4d4da85ee8598d4dc86
1 # -*- encoding: binary -*-
2 # :enddoc:
3 class Rainbows::Fiber::Coolio::Heartbeat < Coolio::TimerWatcher
4   # ZZ gets populated by read_expire in rainbows/fiber/io/methods
5   ZZ = Rainbows::Fiber::ZZ
6   def on_timer
7     exit if (! Rainbows.tick && Rainbows.cur <= 0)
8     now = Time.now
9     fibs = []
10     ZZ.delete_if { |fib, time| now >= time ? fibs << fib : ! fib.alive? }
11     fibs.each { |fib| fib.resume if fib.alive? }
12   end
13 end