Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

concurency support spec: simplify pool method

  • Loading branch information...
commit 9eb768953ed47c70038cead4aa788b2bd43bfdbf 1 parent 2102a8f
authored October 15, 2012

Showing 1 changed file with 4 additions and 7 deletions. Show diff stats Hide diff stats

  1. 11  spec/concurrency_support_spec.rb
11  spec/concurrency_support_spec.rb
@@ -7,14 +7,11 @@
7 7
     module Concurrency
8 8
       # run block in its own thread, create +size+ threads
9 9
       def pool(size)
10  
-        body = proc do |x|
11  
-          ActiveRecord::Base.connection_pool.with_connection do
12  
-            yield x
  10
+        size.times.map { |x|
  11
+          Thread.new do
  12
+            ActiveRecord::Base.connection_pool.with_connection { yield x }
13 13
           end
14  
-        end
15  
-        threads = size.times.map { |x| Thread.new { body.call(x) } }
16  
-
17  
-        threads.each(&:join)
  14
+        }.each(&:join)
18 15
       end
19 16
     end
20 17
     include Concurrency

0 notes on commit 9eb7689

Please sign in to comment.
Something went wrong with that request. Please try again.