<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array">
    <added>
      <filename>ruby/test/threading/.gitignore</filename>
    </added>
  </added>
  <modified type="array">
    <modified>
      <diff>@@ -1,20 +1,6 @@
 require 'monitor'
 
 module Ferret::Index
-  module SynchroLockMixin
-    def synchrolock
-      trys = 5
-      begin
-        synchronize {yield}
-      rescue Ferret::Store::Lock::LockError =&gt; e
-        if (trys -= 1) &lt;= 0
-          raise e
-        else
-          retry
-        end
-      end
-    end
-  end
   # This is a simplified interface to the index. See the TUTORIAL for more
   # information on how to use this class.
   class Index
@@ -138,7 +124,7 @@ module Ferret::Index
         @dir = RAMDirectory.new
       end
 
-      @dir.extend(MonitorMixin).extend(SynchroLockMixin)
+      @dir.extend(MonitorMixin) unless @dir.kind_of? MonitorMixin
       options[:dir] = @dir
       options[:lock_retry_time]||= 2
       @options = options
@@ -275,7 +261,7 @@ module Ferret::Index
     # 
     # See FieldInfos for more information on how to set field properties.
     def add_document(doc, analyzer = nil)
-      @dir.synchrolock do
+      @dir.synchronize do
         ensure_writer_open()
         if doc.is_a?(String) or doc.is_a?(Array)
           doc = {@default_input_field =&gt; doc}
@@ -529,7 +515,7 @@ module Ferret::Index
     # term and the documents that contain that term in the +:id_field+ will be
     # deleted.
     def delete(arg)
-      @dir.synchrolock do
+      @dir.synchronize do
         if arg.is_a?(String) or arg.is_a?(Symbol)
           ensure_writer_open()
           @writer.delete(@id_field, arg.to_s)
@@ -552,7 +538,7 @@ module Ferret::Index
     #         string (in which case it is parsed by the standard query parser)
     #         or an actual query object.
     def query_delete(query)
-      @dir.synchrolock do
+      @dir.synchronize do
         ensure_writer_open()
         ensure_searcher_open()
         query = do_process_query(query)
@@ -581,7 +567,7 @@ module Ferret::Index
     #           the :key attribute.
     # new_doc:: The document to replace the old document with
     def update(id, new_doc)
-      @dir.synchrolock do
+      @dir.synchronize do
         ensure_writer_open()
         delete(id)
         if id.is_a?(String) or id.is_a?(Symbol)
@@ -638,7 +624,7 @@ module Ferret::Index
     #
     # docs:: A Hash of id/document pairs. The set of documents to be updated
     def batch_update(docs)
-      @dir.synchrolock do
+      @dir.synchronize do
         ids = values = nil
         case docs
         when Array
@@ -686,7 +672,7 @@ module Ferret::Index
     #     #=&gt; {:id =&gt; &quot;28&quot;, :title =&gt; &quot;My Oh My&quot;, :artist =&gt; &quot;David Gray&quot;}
     #
     def query_update(query, new_val)
-      @dir.synchrolock do
+      @dir.synchronize do
         ensure_writer_open()
         ensure_searcher_open()
         docs_to_add = []
@@ -741,7 +727,7 @@ module Ferret::Index
     # optimizes the index. This should only be called when the index will no
     # longer be updated very often, but will be read a lot.
     def optimize()
-      @dir.synchrolock do
+      @dir.synchronize do
         ensure_writer_open()
         @writer.optimize()
         @writer.close()
@@ -769,7 +755,7 @@ module Ferret::Index
     #
     # After this completes, the index is optimized.
     def add_indexes(indexes)
-      @dir.synchrolock do
+      @dir.synchronize do
         ensure_writer_open()
         indexes = [indexes].flatten   # make sure we have an array
         return if indexes.size == 0 # nothing to do
@@ -812,7 +798,7 @@ module Ferret::Index
         elsif directory.is_a?(Ferret::Store::Directory)
           @dir = directory
         end
-        @dir.extend(MonitorMixin).extend(SynchroLockMixin)
+        @dir.extend(MonitorMixin) unless @dir.kind_of? MonitorMixin
         @options[:dir] = @dir
         @options[:create_if_missing] = true
         add_indexes([old_dir])
@@ -854,7 +840,7 @@ module Ferret::Index
     # Returns the field_infos object so that you can add new fields to the
     # index.
     def field_infos
-      @dir.synchrolock do
+      @dir.synchronize do
         ensure_writer_open()
         return @writer.field_infos
       end</diff>
      <filename>ruby/lib/ferret/index.rb</filename>
    </modified>
    <modified>
      <filename>ruby/lib/ferret/number_tools.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,3 +1,5 @@
+$:.unshift('.')
+require 'monitor'
 require File.dirname(__FILE__) + &quot;/../test_helper&quot;
 require File.dirname(__FILE__) + &quot;/number_to_spoken.rb&quot;
 require 'thread'
@@ -21,6 +23,7 @@ class IndexThreadSafetyTest &lt; Test::Unit::TestCase
   def indexing_thread()
     index = Index.new(:path =&gt; INDEX_DIR,
                       :analyzer =&gt; ANALYZER,
+                      :auto_flush =&gt; true,
                       :default_field =&gt; :content)
 
     ITERATIONS.times do
@@ -37,6 +40,10 @@ class IndexThreadSafetyTest &lt; Test::Unit::TestCase
       end
       index.commit
     end
+  rescue Exception =&gt; e
+    puts e
+    puts e.backtrace
+    raise 'hell'
   end 
 
   def do_optimize(index)
@@ -74,6 +81,8 @@ class IndexThreadSafetyTest &lt; Test::Unit::TestCase
       threads &lt;&lt; Thread.new { indexing_thread }
     end
 
-    threads.each {|t| t.join}
+    threads.each {|t| 
+      t.join
+    }
   end
 end</diff>
      <filename>ruby/test/threading/thread_safety_index_test.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,20 +1,19 @@
 require File.dirname(__FILE__) + &quot;/../test_helper&quot;
-require File.dirname(__FILE__) + &quot;/../utils/number_to_spoken.rb&quot;
+require File.dirname(__FILE__) + &quot;/number_to_spoken.rb&quot;
 require 'thread'
 
 class IndexThreadSafetyReadWriteTest &lt; Test::Unit::TestCase
   include Ferret::Index
-  include Ferret::Document
 
   INDEX_DIR = File.expand_path(File.join(File.dirname(__FILE__), &quot;index&quot;))
   ITERATIONS = 10000
   ANALYZER = Ferret::Analysis::Analyzer.new()
 
   def setup
-    @index = Index.new(:path =&gt; 'index2',
+    @index = Index.new(:path =&gt; INDEX_DIR,
                        :create =&gt; true,
                        :analyzer =&gt; ANALYZER,
-                       :default_field =&gt; 'contents')
+                       :default_field =&gt; :content)
   end
 
   def search_thread()
@@ -42,10 +41,8 @@ class IndexThreadSafetyReadWriteTest &lt; Test::Unit::TestCase
   end 
 
   def do_add_doc
-    d = Document.new()
     n = rand(0xFFFFFFFF)
-    d &lt;&lt; Field.new(&quot;id&quot;, n.to_s, Field::Store::YES, Field::Index::UNTOKENIZED)
-    d &lt;&lt; Field.new(&quot;contents&quot;, n.to_spoken, Field::Store::NO, Field::Index::TOKENIZED)
+    d = {:id =&gt; n.to_s, :content =&gt; n.to_spoken}
     puts(&quot;Adding #{n}&quot;)
     begin
       @index &lt;&lt; d</diff>
      <filename>ruby/test/threading/thread_safety_read_write_test.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>ec888d92193cea6a087a6bead6d69817be46f64d</id>
    </parent>
  </parents>
  <author>
    <name>David Balmain</name>
    <email>dbalmain@gmail.com</email>
  </author>
  <url>http://github.com/dbalmain/ferret/commit/9f23002c6eb7b513ed9b26b45bc4b34d07b74373</url>
  <id>9f23002c6eb7b513ed9b26b45bc4b34d07b74373</id>
  <committed-date>2009-09-02T18:05:34-07:00</committed-date>
  <authored-date>2009-09-02T18:00:45-07:00</authored-date>
  <message>Fixed threading in Ferret::Index::Index</message>
  <tree>4d74dbf27e3ebda40952d2dbdf11edb797227813</tree>
  <committer>
    <name>David Balmain</name>
    <email>dbalmain@gmail.com</email>
  </committer>
</commit>
