Sha256: a2178109ed56ce8c79e5f41af33a8aa9752d8b8eea1df219e4661d5ac7879e0c
Contents?: true
Size: 425 Bytes
Versions: 41
Compression:
Stored size: 425 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(workers * 2) @threads = Array.new 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
41 entries across 41 versions & 1 rubygems