Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Crystal version doesn't compile with 1.4.1 #80

Open
wcazzola opened this issue May 23, 2022 · 0 comments
Open

Crystal version doesn't compile with 1.4.1 #80

wcazzola opened this issue May 23, 2022 · 0 comments

Comments

@wcazzola
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant