Skip to content

Instantly share code, notes, and snippets.

@amitmurthy
Created March 21, 2017 11:40
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 amitmurthy/9fa364c5e2cc07381bdc83d6f854de97 to your computer and use it in GitHub Desktop.
Save amitmurthy/9fa364c5e2cc07381bdc83d6f854de97 to your computer and use it in GitHub Desktop.
function foo(n)
for i in 1:10^n
produce(i)
end
end
function bar(t,n)
for i in 1:10^n
consume(t,i)
end
end
function baz(n)
t = @schedule foo(n)
@time bar(t,n)
end
baz(1)
baz(5)
function foo(c, n)
for i in 1:10^n
put!(c, i)
end
end
function bar(c, n)
for i in 1:10^n
take!(c)
end
end
function baz(n)
c = Channel{Int}(0)
@schedule foo(c, n)
@time bar(c, n)
end
baz(1)
baz(5)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment