Sha256: a72a30b9a2e4f49a3cc8e7cf7df3d88bd474a61b0685990a0c8bfb6b22ec909b
Contents?: true
Size: 483 Bytes
Versions: 12
Compression:
Stored size: 483 Bytes
Contents
module Pallets class Pool def initialize(size) raise ArgumentError, 'Pool needs a block to initialize' unless block_given? @queue = Queue.new @size = size size.times { @queue << yield } end def size @queue.size end def execute raise ArgumentError, 'Pool needs a block to execute' unless block_given? begin item = @queue.pop yield item ensure @queue << item end end end end
Version data entries
12 entries across 12 versions & 1 rubygems