Project

General

Profile

Bug #20780 » concurrent.rb

demo script - hms (Hal Spitz), 10/02/2024 11:48 PM

 
require 'concurrent-ruby'

rediculously_large_number = 25_000

counter = Concurrent::AtomicFixnum.new(0)

rediculously_large_number.times do |iter|
puts "Iter #{iter}" if iter % 1000 == 0
Concurrent::Promises.future(counter) do
sleep rand(5..15)
counter.increment
end
end

puts "waiting on futures"
while counter.value < futures
puts counter.value
sleep 1
end
(1-1/3)