123456789_123456789_123456789_123456789_123456789_

Class: ActiveSupport::Testing::Parallelization

Do not use. This class is for internal use only.

Class Attribute Summary

Class Method Summary

Instance Attribute Summary

Instance Method Summary

Constructor Details

.new(worker_count) ⇒ Parallelization

[ GitHub ]

  
# File 'activesupport/lib/active_support/testing/parallelization.rb', line 28

def initialize(worker_count)
  @worker_count = worker_count
  @queue_server = Server.new
  @worker_pool = []
  @url = DRb.start_service("drbunix:", @queue_server).uri
end

Class Attribute Details

.after_fork_hooks (readonly) Also known as: #after_fork_hooks

[ GitHub ]

  
# File 'activesupport/lib/active_support/testing/parallelization.rb', line 18

cattr_reader :after_fork_hooks

.run_cleanup_hooks (readonly) Also known as: #run_cleanup_hooks

[ GitHub ]

  
# File 'activesupport/lib/active_support/testing/parallelization.rb', line 26

cattr_reader :run_cleanup_hooks

Class Method Details

.after_fork_hook(&blk)

[ GitHub ]

  
# File 'activesupport/lib/active_support/testing/parallelization.rb', line 14

def self.after_fork_hook(&blk)
  @@after_fork_hooks << blk
end

.run_cleanup_hook(&blk)

[ GitHub ]

  
# File 'activesupport/lib/active_support/testing/parallelization.rb', line 22

def self.run_cleanup_hook(&blk)
  @@run_cleanup_hooks << blk
end

Instance Attribute Details

#after_fork_hooks (readonly)

[ GitHub ]

  
# File 'activesupport/lib/active_support/testing/parallelization.rb', line 18

cattr_reader :after_fork_hooks

#run_cleanup_hooks (readonly)

[ GitHub ]

  
# File 'activesupport/lib/active_support/testing/parallelization.rb', line 26

cattr_reader :run_cleanup_hooks

Instance Method Details

#<<(work)

[ GitHub ]

  
# File 'activesupport/lib/active_support/testing/parallelization.rb', line 41

def <<(work)
  @queue_server << work
end

#shutdown

[ GitHub ]

  
# File 'activesupport/lib/active_support/testing/parallelization.rb', line 49

def shutdown
  @queue_server.shutdown
  @worker_pool.each { |pid| Process.waitpid pid }
end

#size

[ GitHub ]

  
# File 'activesupport/lib/active_support/testing/parallelization.rb', line 45

def size
  @worker_count
end

#start

[ GitHub ]

  
# File 'activesupport/lib/active_support/testing/parallelization.rb', line 35

def start
  @worker_pool = @worker_count.times.map do |worker|
    Worker.new(worker, @url).start
  end
end