# class Chef::ChefFS::Parallelizer

### Public Class Methods

new(threads) click to toggle source

    # File lib/chef/chef_fs/parallelizer.rb, line 19
    def initialize(threads)
      @tasks_mutex = Mutex.new
      @tasks = []
      @threads = []
      1.upto(threads) do
        @threads << Thread.new { worker_loop }
      end
    end

parallelize(enumerator, options = {}, &block) click to toggle source

    # File lib/chef/chef_fs/parallelizer.rb, line 14
    def self.parallelize(enumerator, options = {}, &block)
      @@parallelizer ||= Parallelizer.new(@@threads)
      @@parallelizer.parallelize(enumerator, options, &block)
    end

threads=(value) click to toggle source

    # File lib/chef/chef_fs/parallelizer.rb, line 7
    def self.threads=(value)
      if @@threads != value
        @@threads = value
        @@parallelizer = nil
      end
    end

### Public Instance Methods

parallelize(enumerator, options = {}, &block) click to toggle source

    # File lib/chef/chef_fs/parallelizer.rb, line 28
    def parallelize(enumerator, options = {}, &block)
      task = ParallelizedResults.new(enumerator, options, &block)
      @tasks_mutex.synchronize do
        @tasks << task
      end
      task
    end