Sha256: 79618245691061df38b044d60593d7f10744c3668a409120da6f9e2601a8b16f
Contents?: true
Size: 452 Bytes
Versions: 5
Compression:
Stored size: 452 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
5 entries across 5 versions & 1 rubygems