class ThreadPool

Public Class Methods

new(threads) click to toggle source
# File lib/org_lang_stats/thread_pool.rb, line 5
def initialize(threads)
    @pool = Queue.new
    threads.times { @pool << 1 }
    @workers = []
end

Public Instance Methods

join_workers() click to toggle source
# File lib/org_lang_stats/thread_pool.rb, line 19
def join_workers
    @workers.map(&:join)
end
run(&block) click to toggle source
# File lib/org_lang_stats/thread_pool.rb, line 11
def run(&block)
    @pool.pop
    @workers << Thread.new do
        block[]
        @pool << 1
    end
end