Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@JeffBezanson
Created May 24, 2019 19:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JeffBezanson/30c46a96f1743d3a92fbdd23779806d2 to your computer and use it in GitHub Desktop.
Save JeffBezanson/30c46a96f1743d3a92fbdd23779806d2 to your computer and use it in GitHub Desktop.
# run in commit c35d1d7f7c9d90e0a00ded1980d6fcd5d06f5433
# fixed by commit f81d4d21862c99e1c0452bdf2613ab9e20da9935
macro par(expr)
thunk = esc(:(()->($expr)))
quote
local task = Task($thunk)
task.sticky = false
schedule(task)
task
end
end
function pfib(n::Int)
if n <= 1
return n
end
t = @par pfib(n-2)
return pfib(n-1) + fetch(t)::Int
end
pfib(31)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment