Skip to content

Commit

Permalink
Shorten
Browse files Browse the repository at this point in the history
  • Loading branch information
piroor committed Apr 14, 2015
1 parent d7b9c4f commit b6f6aa5
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions lib/droonga/client/connection/droonga-protocol/thread.rb
Expand Up @@ -78,8 +78,9 @@ def subscribe(message, options={}, &block)
message["from"] = receive_end_point
send(message, options)

timeout_seconds = options[:timeout_seconds]
receive_options = {
:timeout => options[:timeout_seconds],
:timeout => timeout_seconds,
}
start = Time.new
sync = block.nil?
Expand All @@ -89,8 +90,8 @@ def subscribe(message, options={}, &block)
receiver.receive(receive_options) do |object|
yielder << object
end
if receive_options[:timeout] and
Time.new - start > receive_options[:timeout]
if timeout_seconds and
Time.new - start > timeout_seconds
break
end
end
Expand All @@ -101,8 +102,8 @@ def subscribe(message, options={}, &block)
begin
loop do
receiver.receive(receive_options, &block)
if receive_options[:timeout] and
Time.new - start > receive_options[:timeout]
if timeout_seconds and
Time.new - start > timeout_seconds
break
end
end
Expand Down

0 comments on commit b6f6aa5

Please sign in to comment.