⚲
Project
General
Profile
Sign in
Register
Home
Projects
Help
Search
:
Ruby master
All Projects
Ruby
»
Ruby master
Overview
Activity
Roadmap
Issues
Repository
Like
Download (378 Bytes)
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
« Previous
1
2
3
Next »
(1-1/3)
Loading...