<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -1,3 +1,5 @@
+0.3.0
+- allow execute to take args, so we can reset the scope
 0.2.1
 - mutex in case Array#&lt;&lt; and Array#shift aren't atomic
 0.2.0</diff>
      <filename>CHANGELOG</filename>
    </modified>
    <modified>
      <diff>@@ -6,4 +6,22 @@ Usage:
 	require &quot;thread_pool&quot;
 	pool = ThreadPool.new(threads = 10)
 	pool.execute { puts &quot;I'm writing from a thread&quot; }
+	pool.join
+	
+It's often useful to make sure that the properties of Ruby's blocks don't bite you.  The following code will usually print three nils, because n keeps changing.
+
+	pool = ThreadPool.new(threads = 10)
+	numbers = [1, 2, 3]
+	while n = numbers.shift
+		pool.execute { puts n.inspect }
+	end
+	pool.join
+	
+Passing arguments to execute avoids this. i.e.:
+
+	pool = ThreadPool.new(threads = 10)
+	numbers = [1, 2, 3]
+	while n = numbers.shift
+		pool.execute(n) {|local| puts local.inspect }
+	end
 	pool.join
\ No newline at end of file</diff>
      <filename>README</filename>
    </modified>
    <modified>
      <diff>@@ -7,11 +7,12 @@ class ThreadPool
     def initialize(queue, mutex)
       @thread = Thread.new do
         loop do
-          mutex.synchronize { @block = queue.shift }
-          if @block
+          mutex.synchronize { @tuple = queue.shift }
+          if @tuple
+            args, block = @tuple
             @active = true
-            @block.call
-            @block.complete = true
+            block.call(*args)
+            block.complete = true
           else
             @active = false
             sleep 0.01
@@ -38,7 +39,7 @@ class ThreadPool
   end
   
   # Runs the block at some time in the near future
-  def execute(&amp;block)
+  def execute(*args, &amp;block)
     init_completable(block)
     
     if @queue_limit &gt; 0
@@ -46,13 +47,13 @@ class ThreadPool
     end
       
     @mutex.synchronize do
-      @queue &lt;&lt; block
+      @queue &lt;&lt; [args, block]
     end
   end
   
   # Runs the block at some time in the near future, and blocks until complete  
-  def synchronous_execute(&amp;block)
-    execute(&amp;block)
+  def synchronous_execute(*args, &amp;block)
+    execute(*args, &amp;block)
     sleep 0.01 until block.complete?
   end
   </diff>
      <filename>lib/thread_pool.rb</filename>
    </modified>
    <modified>
      <diff>@@ -30,6 +30,31 @@ class TestThreadPool &lt; Test::Unit::TestCase
     assert_equal n - THREADS, @pool.waiting
   end
   
+  class A
+    def initialize(i)
+      @i = i
+    end
+    attr_reader :i
+  end
+  
+  def test_context
+    @foo = []
+    @bar = (0...5).to_a
+    while c = @bar.shift
+      @pool.execute { @foo &lt;&lt; c }
+    end
+    @pool.join
+    assert_equal [nil] * 5, @foo
+    
+    @foo = []
+    @bar = (0...5).to_a
+    while c = @bar.shift
+      @pool.execute(c) {|n| @foo &lt;&lt; n }
+    end
+    @pool.join
+    assert_equal (0...5).to_a, @foo
+  end
+  
   def test_queue_limit
     n = 50
     @foo = 0</diff>
      <filename>test/test_thread_pool.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>edc6797387de3355ccac6bcdebbdab4c6b7fe05d</id>
    </parent>
  </parents>
  <author>
    <name>Kyle Maxwell</name>
    <email>kyle@kyle-maxwells-macbook.local</email>
  </author>
  <url>http://github.com/fizx/thread_pool/commit/c4a61a495177b212f54d62b5b4d8a842c9ed4d4f</url>
  <id>c4a61a495177b212f54d62b5b4d8a842c9ed4d4f</id>
  <committed-date>2008-09-24T20:59:54-07:00</committed-date>
  <authored-date>2008-09-24T20:59:54-07:00</authored-date>
  <message>prevent scope gotchas</message>
  <tree>ec8aa4ae3f5ec1126f36e1cd67a5f70e607f4094</tree>
  <committer>
    <name>Kyle Maxwell</name>
    <email>kyle@kyle-maxwells-macbook.local</email>
  </committer>
</commit>
