Skip to content

Instantly share code, notes, and snippets.

@tk3369
Last active March 28, 2022 07:45
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 tk3369/ec5449698e2b30d82042f88f9eb2111c to your computer and use it in GitHub Desktop.
Save tk3369/ec5449698e2b30d82042f88f9eb2111c to your computer and use it in GitHub Desktop.
function stream_user_input(c::Channel)
while true
line = readline()
if line == ""
put!(c, ">>bye")
break
else
put!(c, line)
end
end
end
function process_inputs(c::Channel)
while true
line = take!(c)
line == ">>bye" && break
@info "Received line: $line"
end
@info "thank you"
end
function main()
c = Channel(5)
@async process_inputs(c)
stream_user_input(c)
end
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment