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

Version Path
mailbox-0.2.7 example/parallel_each_example.rb
mailbox-0.2.6 example/parallel_each_example.rb
mailbox-0.2.5 example/parallel_each_example.rb
mailbox-0.2.4 example/parallel_each_example.rb
mailbox-0.2.3 example/parallel_each_example.rb
mailbox-0.2.2 example/parallel_each_example.rb
mailbox-0.2.1 example/parallel_each_example.rb
mailbox-0.2.0 example/parallel_each_example.rb
mailbox-0.1.7 example/parallel_each_example.rb
mailbox-0.1.6 example/parallel_each_example.rb
mailbox-0.1.4 example/parallel_each_example.rb
mailbox-0.1.3 example/parallel_each_example.rb