Skip to content

Instantly share code, notes, and snippets.

@dinocosta
Created February 6, 2019 11:58
Show Gist options
  • Select an option

  • Save dinocosta/619ac46e3c8a545701c964a292dde73d to your computer and use it in GitHub Desktop.

Select an option

Save dinocosta/619ac46e3c8a545701c964a292dde73d to your computer and use it in GitHub Desktop.
defmodule Processor do
def process(number) do
:timer.sleep(10000 - (number * 1000))
number
end
end
1..10
|> Task.async_stream(&Processor.process/1, on_timeout: :kill_task)
|> Enum.to_list()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment