[Groonga-commit] droonga/fluent-plugin-droonga at 662092d [master] catalog observer: use the default loop to observe catalog

Back to archive index

Kouhei Sutou null+****@clear*****
Sun Mar 23 20:43:18 JST 2014


Kouhei Sutou	2014-03-23 20:43:18 +0900 (Sun, 23 Mar 2014)

  New Revision: 662092d76a217ed2047fa8ab97ffdb32cc4b3122
  https://github.com/droonga/fluent-plugin-droonga/commit/662092d76a217ed2047fa8ab97ffdb32cc4b3122

  Message:
    catalog observer: use the default loop to observe catalog

  Modified files:
    lib/droonga/catalog_observer.rb

  Modified: lib/droonga/catalog_observer.rb (+7 -19)
===================================================================
--- lib/droonga/catalog_observer.rb    2014-03-23 19:57:28 +0900 (3be1656)
+++ lib/droonga/catalog_observer.rb    2014-03-23 20:43:18 +0900 (d2d2d91)
@@ -34,29 +34,17 @@ module Droonga
     end
 
     def start
-      @loop = Cool.io::Loop.new
-      attach(@loop)
-      @thread = Thread.new do
-        begin
-          @loop.run
-        rescue => error
-          logger.exception("error in catalog observing thread", error)
-        end
+      @watcher = Cool.io::TimerWatcher.new(CHECK_INTERVAL, true)
+      observer = self
+      @watcher.on_timer do
+        observer.ensure_latest_catalog_loaded
       end
+      loop = Coolio::Loop.default
+      @watcher.attach(loop)
     end
 
     def stop
-      @loop.stop
-      @thread.join
-    end
-
-    def attach(loop)
-      watcher = Cool.io::TimerWatcher.new(CHECK_INTERVAL, true)
-      observer = self
-      watcher.on_timer do
-        observer.ensure_latest_catalog_loaded
-      end
-      loop.attach(watcher)
+      @watcher.detach
     end
 
     def ensure_latest_catalog_loaded
-------------- next part --------------
HTML����������������������������...
Download 



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