Created
March 21, 2017 11:40
-
-
Save amitmurthy/9fa364c5e2cc07381bdc83d6f854de97 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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