+ while (true)
+ begin
+ diff = floodgate.next_time - Time.now
+ if diff > 0
+ sleep(diff/2)
+ next
+ end
+ LEAGUE.reload
+ floodgate.match_game
+ floodgate.charge
+ next_time = floodgate.next_time
+ $mutex.synchronize do
+ log_message("Reloading source...")
+ ShogiServer.reload
+ end
+ floodgate = ShogiServer::League::Floodgate.new(LEAGUE, next_time)
+ log_message("Floodgate will start the next match at %s." %
+ [floodgate.next_time])
+ rescue Exception => ex
+ # ignore errors
+ log_error("[in Floodgate's thread] #{ex} #{ex.backtrace}")
+ end
+ end
+ end
+end