[Groonga-commit] droonga/droonga-client-ruby at 531168a [master] Support break from receive

Back to archive index

Kouhei Sutou null+****@clear*****
Tue Jan 28 15:08:29 JST 2014


Kouhei Sutou	2014-01-28 15:08:29 +0900 (Tue, 28 Jan 2014)

  New Revision: 531168acd53af460e0db736e7f2d7c57a1e378e8
  https://github.com/droonga/droonga-client-ruby/commit/531168acd53af460e0db736e7f2d7c57a1e378e8

  Message:
    Support break from receive

  Modified files:
    lib/droonga/client/connection/droonga_protocol.rb

  Modified: lib/droonga/client/connection/droonga_protocol.rb (+10 -2)
===================================================================
--- lib/droonga/client/connection/droonga_protocol.rb    2014-01-28 15:02:48 +0900 (f24dc8d)
+++ lib/droonga/client/connection/droonga_protocol.rb    2014-01-28 15:08:29 +0900 (f06dfce)
@@ -224,6 +224,7 @@ module Droonga
           BUFFER_SIZE = 8192
           def receive(options={}, &block)
             timeout = options[:timeout]
+            catch do |tag|
             loop do
               start = Time.new
               readable_ios, = IO.select(@read_ios, nil, nil, timeout)
@@ -232,10 +233,17 @@ module Droonga
                 timeout -= (Time.now - start)
                 timeout = 0 if timeout < 0
               end
-              readable_ios.each do |readable_io|
-                on_readable(readable_io, &block)
+                readable_ios.each do |readable_io|
+                on_readable(readable_io) do |object|
+                  begin
+                    yield(object)
+                  rescue LocalJumpError
+                    throw(tag)
+                  end
+                end
               end
             end
+            end
           end
 
           private
-------------- next part --------------
HTML����������������������������...
Download 



More information about the Groonga-commit mailing list
Back to archive index