Sha256: f97a3c3936bec8b11839c2d54b3a65115f6c76df15e1ff5517bab41d3249761d

Contents?: true

Size: 543 Bytes

Versions: 3

Compression:

Stored size: 543 Bytes

Contents

#!/usr/bin/env ruby

require "rubygems"
require "#{File.dirname(__FILE__)}/../lib/pigato.rb"
#require "pigato"

def start
  ts = []

  (0..5).each do |tid|
    ts << Thread.new {
      worker = Pigato::Worker.new('tcp://127.0.0.1:55555', 'echo')
      worker.start

      loop do
        request = worker.recv
        if !request.nil?
          worker.reply request
        else
          sleep 0.1
        end
      end
    }
  end

  ts.each do |to|
    to.join
  end
end

(0..1).each do |pid|
  fork do
    start
  end
end

Process.waitall

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
pigato-0.4.2 examples/echo_worker.rb
pigato-0.4.1 examples/echo_worker.rb
pigato-0.4.0 examples/echo_worker.rb