Module: ArrayThreadedEnumerable
- Defined in:
- lib/dispatch_queue.rb
Instance Method Summary collapse
Instance Method Details
#threaded_each ⇒ Object
14 15 16 17 18 19 20 21 22 |
# File 'lib/dispatch_queue.rb', line 14 def threaded_each threads = [] each { |value| threads << Thread.new { yield value } } threads.each{|t| t.join} end |
#threaded_map ⇒ Object
24 25 26 27 28 29 30 31 |
# File 'lib/dispatch_queue.rb', line 24 def threaded_map values = [] threaded_each { |value| value = yield value Thread.exclusive { values << value } } values end |