[Groonga-commit] droonga/droonga-engine at 829cdf3 [master] dump: use Fiber instead of Enumerator

Back to archive index

Kouhei Sutou null+****@clear*****
Fri May 2 15:28:07 JST 2014


Kouhei Sutou	2014-05-02 15:28:07 +0900 (Fri, 02 May 2014)

  New Revision: 829cdf3aa9aac734f56f53092c552a17443caee8
  https://github.com/droonga/droonga-engine/commit/829cdf3aa9aac734f56f53092c552a17443caee8

  Message:
    dump: use Fiber instead of Enumerator

  Modified files:
    lib/droonga/plugins/dump.rb

  Modified: lib/droonga/plugins/dump.rb (+4 -4)
===================================================================
--- lib/droonga/plugins/dump.rb    2014-04-30 17:24:18 +0900 (7814261)
+++ lib/droonga/plugins/dump.rb    2014-05-02 15:28:07 +0900 (f9fb7e5)
@@ -33,7 +33,7 @@ module Droonga
           messages_per_seconds = request["messagesPerSecond"] || 10000
           messages_per_seconds = [10, messages_per_seconds.to_i].max
           messages_per_100msec = messages_per_seconds / 10
-          dumper = Enumerator.new do |yielder|
+          dumper = Fiber.new do
             n = 0
             each_table do |table|
               table.each do |record|
@@ -53,7 +53,7 @@ module Droonga
                                   "to" => replyTo,
                                   "type" => "dump.record")
                 n = (n + 1) % messages_per_100msec
-                yielder << nil if n.zero?
+                Fiber.yield if n.zero?
               end
             end
           end
@@ -61,8 +61,8 @@ module Droonga
           timer = Coolio::TimerWatcher.new(0.1, true)
           timer.on_timer do
             begin
-              dumper.next
-            rescue StopIteration
+              dumper.resume
+            rescue FiberError
               timer.detach
             end
           end
-------------- next part --------------
HTML����������������������������...
下載 



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