You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
As in the subject the Crystal version doesn't compile with version 1.4.1, something has changed.
This is how it should be:
`def skynet(c, num, size, div)
if size == 1
c.send num
else
rc = Channel(Int64|Float64).new
sum = 0_i64
div.times do |i|
sub_num = num + i*(size/div)
spawn skynet(rc, sub_num, size/div, div)
end
div.times do
sum += rc.receive
end
c.send sum
end
end
c = Channel(Int64|Float64).new
start_time = Time.local
spawn skynet(c, 0_i64, 1_000_000, 10)
result = c.receive
end_time = Time.local
puts "Result: #{result} in #{(end_time - start_time).total_milliseconds.to_i}ms."`
Note for linux users, the number of allowed threads have to be raised with
sysctl -w vm.max_map_count=10000000
The text was updated successfully, but these errors were encountered:
As in the subject the Crystal version doesn't compile with version 1.4.1, something has changed.
This is how it should be:
`def skynet(c, num, size, div)
if size == 1
c.send num
else
rc = Channel(Int64|Float64).new
sum = 0_i64
div.times do |i|
sub_num = num + i*(size/div)
spawn skynet(rc, sub_num, size/div, div)
end
div.times do
sum += rc.receive
end
c.send sum
end
end
c = Channel(Int64|Float64).new
start_time = Time.local
spawn skynet(c, 0_i64, 1_000_000, 10)
result = c.receive
end_time = Time.local
puts "Result: #{result} in #{(end_time - start_time).total_milliseconds.to_i}ms."`
Note for linux users, the number of allowed threads have to be raised with
The text was updated successfully, but these errors were encountered: