Sha256: 4656efaaa0f296fd945da1f28143b274c3364e03a0d4db0805aeedc7ae4a38c9
Contents?: true
Size: 431 Bytes
Versions: 13
Compression:
Stored size: 431 Bytes
Contents
# frozen_string_literal: true module Relaton # Workers poll. class WorkersPool def initialize(workers = 2, &_block) num_workers = workers < 2 ? 2 : workers @queue = SizedQueue.new(num_workers * 2) @threads = Array.new num_workers do Thread.new do while item = @queue.pop; yield(item) end end end end def <<(item) @queue << item self end end end
Version data entries
13 entries across 13 versions & 1 rubygems