Sha256: f8578a1ae4dc70712263d4fd0aaea004e31a414b870f808471ab61347d574ada
Contents?: true
Size: 582 Bytes
Versions: 12
Compression:
Stored size: 582 Bytes
Contents
require 'rubygems' require 'test/unit' require File.dirname(__FILE__) + "/../lib/mailbox" class DataProcessor include Mailbox mailslot def process(data) p "#{data} was processed by Thread# #{Thread.current.object_id}" end end class ParallelEachExample < Test::Unit::TestCase def test_a_simple_parallel_each items = ["item1", "item2", "item3", "item4", "item5"] processors = [DataProcessor.new, DataProcessor.new, DataProcessor.new] items.each_with_index do |item, index| processors[index % processors.length].process item end end end
Version data entries
12 entries across 12 versions & 1 rubygems