YUKI Hiroshi
null+****@clear*****
Tue Apr 14 20:36:38 JST 2015
YUKI Hiroshi 2015-04-14 20:36:38 +0900 (Tue, 14 Apr 2015) New Revision: e6d177b2672d03d4afe15c9253718d9ea315cfc3 https://github.com/droonga/droonga-client-ruby/commit/e6d177b2672d03d4afe15c9253718d9ea315cfc3 Message: Separate subscription timeout and receiver timeout Modified files: lib/droonga/client/connection/droonga-protocol/coolio.rb lib/droonga/client/connection/droonga-protocol/thread.rb Modified: lib/droonga/client/connection/droonga-protocol/coolio.rb (+4 -4) =================================================================== --- lib/droonga/client/connection/droonga-protocol/coolio.rb 2015-04-14 20:17:48 +0900 (3b2d34e) +++ lib/droonga/client/connection/droonga-protocol/coolio.rb 2015-04-14 20:36:38 +0900 (e67c905) @@ -41,12 +41,12 @@ module Droonga def initialize(loop, options={}) @loop = loop - @timeout_seconds = options[:timeout_seconds] + @subscription_timeout = options[:subscription_timeout] end def wait - if @timeout_seconds - @timer = Coolio::TimerWatcher.new(@timeout_seconds) + if @subscription_timeout + @timer = Coolio::TimerWatcher.new(@subscription_timeout) @timer.on_timer do @timer.detach @on_timeout.call if @on_timeout @@ -229,7 +229,7 @@ module Droonga id = message["id"] request_options = { - :timeout_seconds => options[:timeout_seconds], + :subscription_timeout => options[:subscription_timeout], } request = InfiniteRequest.new(@loop, request_options) request.on_timeout = lambda do Modified: lib/droonga/client/connection/droonga-protocol/thread.rb (+12 -3) =================================================================== --- lib/droonga/client/connection/droonga-protocol/thread.rb 2015-04-14 20:17:48 +0900 (c8b1780) +++ lib/droonga/client/connection/droonga-protocol/thread.rb 2015-04-14 20:36:38 +0900 (3a88a08) @@ -78,9 +78,10 @@ module Droonga message["from"] = receive_end_point send(message, options) - timeout_seconds = options[:timeout_seconds] + subscription_timeout = options[:subscription_timeout] + start = Time.now receive_options = { - :timeout => timeout_seconds, + :timeout => options[:timeout], } sync = block.nil? if sync @@ -89,6 +90,10 @@ module Droonga receiver.receive(receive_options) do |object| yielder << object end + if subscription_timeout + elapsed_seconds = Time.now - start + break if elapsed_seconds >= subscription_timeout + end end receiver.close end @@ -97,6 +102,10 @@ module Droonga begin loop do receiver.receive(receive_options, &block) + if subscription_timeout + elapsed_seconds = Time.now - start + break if elapsed_seconds >= subscription_timeout + end end ensure receiver.close @@ -164,7 +173,7 @@ module Droonga timeout = options[:timeout] catch do |tag| loop do - start = Time.new + start = Time.now readable_ios, = IO.select(@read_ios, nil, nil, timeout) break if readable_ios.nil? if timeout -------------- next part -------------- HTML����������������������������...Download